本文最后更新于509 天前,其中的信息可能已经过时,如有错误请发送邮件到84581927@qq.com
— Generate a filename
excelFile = “C:\\test.xls
— Start an Excel OLE Object
x = CreateOLEObject “Excel.Application
— Create a new workbook in the new excel document
x.application.Workbooks.Add
— Give the active sheet a name (“Test
x.ActiveSheet.Name = “Test”
— This makes Excel Visible
x.visible = true
— Put some content into Cell A1
(x.application.Range(“A1”)).value = “This is Cell A1”
— Change the color of A1:B1 to red
(x.application.Range(“A1:B1”)).Interior.ColorIndex = 45
— Save the spreadsheet
x.application.ActiveWorkbook.SaveAs(excelFile)
— Close the spreadsheet
x.application.ActiveWorkbook.Close
— quit excel
x.quit()
— Release the OLE Object
releaseOLEObject x
— Release ALL OLE Objects, just incase
releaseAllOLEObjects()