FilePath = d:\def\test.xlsx
;创建一个excel文件处理并保存
;作者: sunwind <[email protected]>
;博客: http://blog.csdn.net/liuyukuan
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
[ahk]怎么新建一个aaa的工作表(sheet)
猜你喜欢
转载自blog.csdn.net/liuyukuan/article/details/80762498
今日推荐
周排行