FilePath = d:\def\test.xlsx
;创建一个excel文件处理并保存
;作者: sunwind
excel := ComObjCreate("Excel.Application")
workBook :=excel.Workbooks.Add
;~ sheet:=excel.Worksheets[2] ;直接操纵sheet2
;~ sheet.Name:= "aaa"
sheet := excel.Worksheets.Add() ; add a new Sheet
sheet.Name := "aaa" ; name new sheet to "aaa"
cell := sheet.Range("B1")
cell.Value := "Hello " ;写Value
cell := sheet.Range("A2")
cell.Value := "World"
cell1 := sheet.Range("A2")
sValue := cell1.Value ; 读Value
MsgBox %sValue%
try
{
workBook.SaveAs(FilePath) ;存盘
}
catch
{
SplitPath,FilePath,,dir
FileCreateDir,%dir%
workBook.SaveAs(FilePath) ;存盘
}
excel.Quit
run %FilePath% ;打开excel