SaveTablesXLSXToStreamEx

Structured table export

Description

Exports editable tables with caller-supplied cell types, input conventions and Excel display formats

Syntax

function TPDFlib.SaveTablesXLSXToStreamEx(const PageRange: WideString;
  Options: Integer; const ColumnRules: TPDFlibXLSXColumnRules;
  Target: TStream): Integer;

Parameters

PageRangeA one-based page range, or an empty string for every page in the document
OptionsOptional worksheet flags; combine PDF_XLSX_AUTOFILTER (1) and PDF_XLSX_REPEAT_PRINT_HEADERS (2), or pass 0 for defaults
ColumnRulesExplicit column types, parsing conventions and display formats. An empty rule array uses the existing inference
TargetThe destination stream, which remains owned by the caller

Page selection, worksheet options and stream ownership follow SaveTablesXLSXToStream. An empty rule array uses the existing inference

Column rules

Sheet, ColumnOne-based worksheet and column numbers. Sheet 0 applies to all worksheets. A sheet-specific rule overrides a sheet 0 rule for the same column. Duplicate rule keys are invalid
CellTypexctAuto uses numeric inference, xctText emits an inline string, xctNumber parses a number, xctDate and xctDateTime emit Excel serial values, and xctBoolean accepts true, false, 1 or 0
DecimalSeparator, GroupSeparatorThe decimal separator defaults to a period. Choose a period or comma and, optionally, a different grouping character. Grouping accepts periods, commas, apostrophes, ordinary spaces, nonbreaking spaces and narrow nonbreaking spaces. Groups after the first must contain exactly three digits
DateOrder, DateSeparatorThe default order is xdoYearMonthDay with a hyphen. xdoDayMonthYear and xdoMonthDayYear default to a slash. A rule may explicitly select a hyphen, slash or period. Supply a four-digit year and two-digit month and day. For xctDateTime, add a space or T and hh:mm:ss
FormatCodeAn Excel custom number format string, such as #,##0.00 or dd.mm.yyyy. It affects display. Date and date-time columns receive a default format when the field is empty
RejectInvalidAn explicit number, date, date-time or Boolean rule can reject nonempty values it cannot parse. With the default value of false, those source values stay as text. Auto and text rules accept their normal text fallback

Rules apply to data cells and continue to apply when a later source page contributes rows to the same worksheet. The workbook uses Excel's 1900 date system. Overprecision values remain text unless the rule requests rejection. Use a text rule to keep leading zeros and identifier spelling

Return values

Returns the number of exported worksheets or zero on failure. Invalid rules or a rejected value report LastErrorCode 114 and leave the stream untouched. A rejected value also identifies its worksheet and cell in GetLastStructuredTextDiagnostics

Example

SetLength(Rules, 2);
Rules[0].Column := 1;
Rules[0].CellType := TPDFlibXLSXCellType.xctText;
Rules[1].Column := 2;
Rules[1].CellType := TPDFlibXLSXCellType.xctNumber;
Rules[1].DecimalSeparator := ',';
Rules[1].GroupSeparator := '.';
Rules[1].FormatCode := '#,##0.00';
Lib.SaveTablesXLSXToStreamEx('', 0, Rules, Target);

Use SaveTablesXLSXToFileEx to publish the completed workbook to a file