函数参考


_ExcelSheetAddNew

添加一个新的工作表到工作区 - 名称可选.

#Include <Excel.au3>
_ExcelSheetAddNew($oExcel [, $sName = ""])

参数

$oExcel 由前面调用 _ExcelBookOpen() 或者 _ExcelBookNew() 函数返回的 Excel 对象
$sName [可选参数] 要创建的工作表的名称(默认根据标准 Excel 新建表格格式添加)

返回值

成功: 返回 1
失败: 返回 0 并设置 @error
@error: 0 - 无错误.
1 - 指定对象不存在.

注意/说明

None

相关

示例/演示


; ***************************************************************
; 示例 1 - 打开工作簿并返回其对象标识符后, 添加一个新的工作表
; *****************************************************************
#include <Excel.au3>

Local $oExcel = _ExcelBookNew() ;创建新工作簿, 并使其可见

_ExcelSheetAddNew($oExcel, "New Sheet Example")

MsgBox(4096, "Exiting", "Press OK to Save File and Exit")
_ExcelBookSaveAs($oExcel, @TempDir & "\Temp.xls", "xls", 0, 1) ; 现在我们把它保存到临时目录; 必要时覆盖文件
_ExcelBookClose($oExcel) ; 最后我们关闭并退出