vb.net操作excel汇集

前端之家收集整理的这篇文章主要介绍了vb.net操作excel汇集前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



        Dim xl As New Excel.Application
        Dim xlBook As Excel.Workbook = xl.Workbooks.Open(strSaveExcelFile)
        Dim xlSheet As Excel.Worksheet = xlBook.Sheets(1)
        Dim col As Integer
        Dim row As Integer

        xlSheet.Range(xlSheet.Cells(1,1),xlSheet.Cells(80,80)).NumberFormat = "@" '文本格式

        For i = 0 To Rlevel.GetUpperBound(0) '标题
            row = 1 + i * 7 + 1
            xlSheet.Cells(1,row) = Rlevel(i) & "分钟累积"
            xlSheet.Cells(1,row + 1) = "结束时间"
            '............
        Next

        '............

        xlSheet.Cells.Font.Size = 9
        xlSheet.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter '所有单元水平居中
        xlSheet.Cells.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter   '所有单元垂直居中

        xlSheet.Cells.EntireColumn.AutoFit()                              '所有列自适合单元宽度
        xlSheet.Range("B2").Activate()
        xl.Application.ActiveWindow.FreezePanes = True                    '冻结窗口B2单元

        xlBook.Save()
        xlBook.Close()
        xl.Quit()
原文链接:/vb/258353.html

猜你在找的VB相关文章