HotXLS Docs

Add method

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

Syntax

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 Optional. An object that specifies the sheet before which the new sheet is added
After TXLSWorksheet Optional. An object that specifies the sheet after which the new sheet is added. The default value is the last Worksheet
Count Integer Optional. The number of sheets to be added. The default value is one
Type_ OleVariant Optional. Determines the sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. The default value is xlWorksheet. This argument is ignored by this library

Example

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);