NativeExcel suite v2.x

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;
BeforeIXLSWorkSheet Optional. An object that specifies the sheet before which the new sheet is added.
AfterIXLSWorkSheet Optional. An object that specifies the sheet after which the new sheet is added. The default value is the last Worksheet.
CountInteger 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 © NikaSoft 2004-2012