1. 程式人生 > >vb.net設定單元格的顏色

vb.net設定單元格的顏色

一學就用!最近為硬體部搞測試軟體,用VB.NET,需要把測試結果儲存到excel文件。

其中某個功能是EXCEL 的單元格需要設定顏色。

        Dim oExcel As New Microsoft.Office.Interop.Excel.Application
        Dim obook As Microsoft.Office.Interop.Excel.Workbook
        Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet

        obook = oExcel.Workbooks.Open(Application.StartupPath & "\testrecord.xls")
        oSheet = obook.Worksheets(1)

            With oSheet
                .Range(.Cells(10, 7), .Cells(recordindex, 18)).Interior.ColorIndex = 33
            End With