本文最后更新于557 天前,其中的信息可能已经过时,如有错误请发送邮件到84581927@qq.com
-- Startup Ops
-- Generate a filename
excelFile = "<path string>\testbook.xlsx"
-- Start an Excel OLE Object
x = CreateOLEObject "Excel.Application"
-- Create a new workbook in the new excel document
x.application.Workbooks.open(excelFile)
-- This makes Excel Visible
x.visible = true
--Here's where I'm having trouble
-- Retrieve the contents of Cell A3
contents = x.ActiveSheet.Cells(3, 1).Value
-- Change the contents of Cell A3 to Hello
x.ActiveSheet.Cells(3, 1).Value = "Hello"
-- Cleanup Ops
-- Close the spreadsheet
x.application.ActiveWorkbook.Close
-- quit excel
x.quit()
-- Release the OLE Object
releaseOLEObject x
-- Release ALL OLE Objects, just in case
releaseAllOLEObjects()