HotXLS Docs

TXLSXSheets class

Worksheet collection on TXLSXWorkbook. Mirrors the IXLSWorkSheets collection on the BIFF facade so that the call style stays consistent across the two formats. Declared in lxHandleX.

Declaration

type
  TXLSXSheets = class
    function Add: TXLSXWorksheet; overload;
    function Add(const AName: WideString): TXLSXWorksheet; overload;
    procedure Clear;
    function IndexByName(const AName: WideString): Integer;
    property Count: Integer;
    property Items[Index: Integer]: TXLSXWorksheet; default;
  end;
      

Members

Add Adds a new worksheet with an auto-generated name (Sheet1, Sheet2, ...). Returns the new TXLSXWorksheet.
Add(AName) Adds a new worksheet with the given name. Returns the new worksheet.
Clear Removes and frees every worksheet in the collection.
IndexByName(AName) Case-insensitive name lookup. Returns the index or -1 if no worksheet has that name.
Count Number of worksheets currently in the workbook.
Items[Index] Worksheet at the given 0-based index. Declared as the default property so Sheets[i] works directly.

Example

var
  i: Integer;
begin
  Workbook.Sheets.Add('Summary');
  Workbook.Sheets.Add('Detail');

  for i := 0 to Workbook.Sheets.Count - 1 do
    WriteLn(Workbook.Sheets[i].Name);

  if Workbook.Sheets.IndexByName('Detail') >= 0 then
    ShowMessage('Detail sheet exists.');
end;
    

See also