HotXLS 文档

Add 方法

Creates a new Worksheet. The new Worksheet becomes the active sheet

语法

function Add: TXLSWorksheet;
function Add(Before, After: TXLSWorksheet; Count: Integer; Type_: OleVariant): TXLSWorksheet;
function Add(Before, After: TXLSWorksheet; Count: Integer): TXLSWorksheet;
function Add(Before, After: TXLSWorksheet): TXLSWorksheet;
Before TXLSWorksheet,可选。一个对象,指定在其之前插入新工作表的工作表
After TXLSWorksheet,可选。一个对象,指定在其之后插入新工作表的工作表。默认值为最后一个工作表
Count Integer Optional. The number of sheets to be added. The default value is one
Type_ OleVariant,可选。指定工作表类型。可以是以下 XlSheetType 常量之一:xlWorksheet、xlChart、xlExcel4MacroSheet 或 xlExcel4IntlMacroSheet。默认值为 xlWorksheet。本库会忽略该参数

示例

This example creates new Worksheet and sets the name to it

Var Worksheet: TXLSWorksheet;
begin
  Worksheet := Workbook.Sheets.Add;
  Worksheet.Name := 'New sheet';
end;
This example creates new Worksheet after second Worksheet

Workbook.Sheets.Add(nil, Workbook.Sheets[2]);
This example is the same to previous

Workbook.Sheets.AddAfter(2);