我正在尝试通过 maxscript 访问单个单元格的值,但我一直很难弄清楚究竟是什么让我无法这样做。这是我在 maxscript 中的内容:
-- 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()
这是我用来参考的msdn资源。据我所知,我跟踪了所有内容。如果有人可以提供帮助,我将不胜感激。