HotXLS Delphi Excel Read Write Library / Component Developers Guide loslab Inc.

Add method

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

Syntax

function Add: IXLSWorksheet;
function Add(Before, After: IXLSWorksheet; Count: Integer; Type_: OleVariant): IXLSWorksheet;
function Add(Before, After: IXLSWorksheet; Count: Integer): IXLSWorksheet;
function Add(Before, After: IXLSWorksheet): IXLSWorksheet;
Before IXLSWorksheet Optional. An object that specifies the sheet before which the new sheet is added.
After IXLSWorksheet 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. Specifies 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: IXLSWorksheet;
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);
Copyright©2007-2019 loslab.com