TXLSTable / TXLSTables classes
Unit: lxHandle
BIFF8 (.xls) Tables (Excel ListObjects). A table attaches a named structured-reference region with a built-in style and an embedded autofilter to a rectangular range. The collection lives on IXLSWorksheet.Tables; use AddTable as the most common entry point. The shape mirrors TXLSXTable / TXLSXTables on the XLSX side, so code that adds tables to a workbook can be format-agnostic. Available since v2.33.0.
Declaration
type
TXLSTable = class
constructor Create;
procedure Assign(Source: TXLSTable);
property Id: Integer; // assigned by SaveAs (1..N per sheet)
property Name: WideString;
property DisplayName: WideString;
property Range: WideString; // e.g. "A1:F9"
property Columns: TStringList; // header text per column
property StyleName: WideString; // default 'TableStyleMedium2'
property ShowFirstColumn: Boolean; // default False
property ShowLastColumn: Boolean; // default False
property ShowRowStripes: Boolean; // default True
property ShowColumnStripes: Boolean; // default False
property TotalsRowShown: Boolean; // default False
end;
TXLSTables = class
function Add: TXLSTable; overload;
function Add(const AName, ARange: WideString;
AColumns: TStrings): Integer; overload;
procedure Delete(Index: Integer);
procedure Clear;
property Count: Integer;
property Items[Index: Integer]: TXLSTable; default;
end;
Worksheet shortcut
IXLSWorksheet
exposes AddTable(AName, ARange, AColumns)
which forwards to Tables.Add and returns the new table
object so you can refine its StyleName or banded-row flags
before save.
Save-time behaviour
On BIFF8 SaveAs(xlExcel97), the sheet emits one
FEATHEADR11 ($0871) table-feature header, then each table emits a
FEAT11 ($0872) TableFeatureType payload plus a LIST12
($0877) style record just before the worksheet EOF, after sheet
protection. Since v2.87.4 the LIST12 style record uses the MS-XLS
List12TableStyleClientInfo layout, including the banded
row / column flags and the style name as an XLUnicodeString.
HotXLS no longer emits the legacy FEATHEADR ($0867) record for table
metadata. Workbooks without tables save exactly as before and carry no
table record-stream overhead. BIFF5 saves are unaffected because Tables
are a BIFF8+ concept.
From v2.33.2 the BIFF8 writer also suppresses the standalone
sheet-level AUTOFILTERINFO / AUTOFILTER
records when a Table on the same sheet fully covers the autofilter
range, because Excel embeds an autofilter dropdown inside the Table
object itself. From v2.87.4 the table's own Feature11
metadata also sets the table-level and field-level AutoFilter flags
and emits the empty per-column Feat11FdaAutoFilter blocks
Excel expects for table filter dropdowns.
Example
var
cols: TStringList;
begin
Sheet.Cells.Item[1, 1].Value := 'Region';
Sheet.Cells.Item[1, 2].Value := 'Product';
Sheet.Cells.Item[1, 3].Value := 'Quarter';
Sheet.Cells.Item[1, 4].Value := 'Revenue';
// ... nine data rows below ...
cols := TStringList.Create;
try
cols.Add('Region');
cols.Add('Product');
cols.Add('Quarter');
cols.Add('Revenue');
with Sheet.AddTable('SalesTable', 'A1:D10', cols) do
begin
StyleName := 'TableStyleMedium2';
ShowRowStripes := True;
end;
finally
cols.Free;
end;
Workbook.SaveAs('SalesTable.xls', xlExcel97);
See also
IXLSWorksheet.AddTable method
IXLSWorksheet.Tables property
TXLSXTable / TXLSXTables (XLSX side)