SaveTablesXLSXToStream

Document conversion, extraction, XLSX, streams

Description

Extracts tables from a PDF page range into a native SpreadsheetML (.xlsx) workbook and writes the ZIP package at the current stream position

Syntax

Function TPDFlib.SaveTablesXLSXToStream(Const PageRange: WideString;
  Options: Integer; Target: TStream): Integer;

Parameters

PageRangeA one-based page range, or an empty string for every page in the document
OptionsOptional worksheet flags; combine 1 for automatic filtering and 2 for repeated print headers, or pass 0 for defaults
TargetThe destination stream, which remains owned by the caller

Return values

Returns the number of exported worksheet tables, or zero when no tables are found or when validation, extraction, or stream writing fails

Remarks

Values exceeding fifteen significant decimal digits are retained as text so long identifiers and precise decimal strings do not silently change in spreadsheet software

Cells containing line breaks receive a wrapping style, while ordinary cells keep their existing style. Consecutive leading rows composed of genuine header cells remain frozen while scrolling; tables without such headers do not receive frozen panes

Each extracted table becomes a dedicated worksheet in the generated workbook, while tables marked as continuing across consecutive pages are appended to the preceding worksheet with repeated continuation headers automatically omitted

Numeric cell values are emitted as native numeric cells (<v>) and text cells are emitted as inline strings (t="inlineStr"), with header row shading, grid borders, column widths, and merged cell ranges (<mergeCells>) preserved

LastErrorCode is 114 for invalid arguments and 518 when no tables are found or packaging fails

Formatting, links, and worksheet options

Cell text retains the first source span's font family, size, color, and emphasis while retaining header shading, borders, and line wrapping; explicit multiline content also receives a suitable custom row height

A cell containing one unique HTTP, HTTPS, FTP, or mail target retains a clickable hyperlink; cells with conflicting targets or unsupported schemes stay ordinary cells

Finite scientific notation such as 1.25e3 and -2E-4 becomes a native numeric cell when the mantissa contains at most fifteen significant digits; overprecision, leading-zero identifiers, out-of-range values, and subnormal numbers remain text

Combine PDF_XLSX_AUTOFILTER (1) and PDF_XLSX_REPEAT_PRINT_HEADERS (2) in Options to enable filtering and repeated printed header rows; zero keeps both features disabled

Filters use the last genuine leading header row and the full data range, and are omitted for merged tables or tables without data rows; print titles repeat every consecutive genuine leading header row on its own sheet

See also

SaveTablesXLSXToFile, SaveDOCXToStream