XLSB formulas and worksheet objects
The XLSX workbook facade reads and writes a validated XLSB subset with typed values, ordinary cached formulas, names, common styles and represented worksheet objects; unrepresented state rejects before destination output
Open and save
if Workbook.Open('values.xlsb') <> 1 then
raise Exception.Create('XLSB input is unsupported or invalid');
if Workbook.SaveAsChecked('values-copy.xlsb', xlsxExcelBinaryWorkbook) <> 1 then
raise Exception.Create('XLSB output is unsupported or failed');
Open detects the workbook part's content and registered type; successful binary input sets SourceFormat=xlsxExcelBinaryWorkbook, while the original four TXLSXFileFormat ordinals remain unchanged and the new member has ordinal 4
The file and stream SaveAs and SaveAsChecked overloads accept the binary format explicitly; default saving still selects the ordinary Open XML workbook format regardless of the filename extension
GetConversionReport(xlsConversionExcelBinaryWorkbook) inspects current state without expanding packed cell storage; unsupported entries remain mandatory failures even for unchecked saving or AllowLossy=True
Supported state
- Ordinary worksheets, Unicode names and strings, numbers, Boolean values, blank and styled blank cells, and ordinary representable error values
- Shared and inline string inputs, compact native numeric and short-cell records, worksheet visibility, the date-system flag, ordinary workbook and worksheet views and selections
- Common fonts, pattern fills, edge borders, number formats, cell format references, alignment and protection flags, and represented RGB, theme and indexed colors
- Row heights, column widths, supported dimension flags and page margins
- Ordinary cell formulas using supported legacy function tokens, scalar operators, A1 references, same-workbook single-sheet references and workbook or worksheet names, with numeric, string, Boolean and ordinary error caches
- Global and worksheet-scoped defined names, hidden-name flags and comments, merged cells, ordinary external and internal hyperlinks, split or frozen panes and pane selections
- AutoFilter ranges, scalar custom comparisons with one or two AND/OR criteria, and arbitrary selected-value lists with an optional blank selection
- Ordinary worksheet tables with identity, range, header and total-row visibility, column identity and captions, literal total-row labels, represented AutoFilter criteria and built-in table style flags
- Configured ZIP compression and deterministic ZIP timestamps through the existing workbook options
The conversion report covers live-model features, and complete package validation remains the final gate for invalid references, malformed records, unfamiliar attributes or unsupported retained content
Binary import retains the file's explicit default font and supported built-in number formats, including styled blank cells; locale-dependent number formats require an explicit format code so the reader does not guess regional formatting
Explicit boundaries
Shared formula records, array and dynamic-array ownership, array constants and array-returning functions, future functions, user-defined functions, external-workbook and multi-sheet references, VBA, external data connections, PivotTables and Slicers, charts and drawings, comments and rich text, validation, conditional formatting and advanced page or extension metadata remain outside this backend
Table calculated columns, total aggregation formulas, sort state, differential or custom table formatting, query-bound tables and XML mappings reject; color, icon, dynamic and date-group filters, typed native Boolean custom criteria, numeric-looking native string custom criteria and filter button visibility overrides also reject
Imported non-custom worksheet filter criteria are retained as RawXml; custom comparisons populate the existing typed criterion properties, while selected values and blank selection remain an XML-backed criterion rather than a new typed value-list API
Formula token conversion preserves semantics and reference flags; it can normalize formula text with parentheses and quoted sheet names, so byte-for-byte text identity is not promised
Formula output requires an explicit numeric, string, Boolean or ordinary error cache; a missing cache rejects when the save policy will not recalculate, including xrmManual and a clean dependency graph with xrmIfDirty; applications can call Recalculate or select xrmAlways before saving, and empty string, False and numeric zero are valid caches
Calculation properties must use supported defaults; manual calculation, iteration, reduced precision, alternate reference mode, forced or incomplete calculation, explicit thread configuration and other meaningful nondefault settings reject
Calculation chains and binary cell indexes are regenerated metadata and are not copied across the package bridge; unfamiliar feature records or relationships remain failures instead of becoming fabricated Open XML parts
Binary input requires eager full-sheet loading; MetadataOnly and a nonempty SelectedSheets list reject before replacing the existing model because lazy loading would require a retained converted archive
Failure and ownership guarantees
Binary packages are validated and converted before the ordinary XML parser resets the workbook; unsupported input, malformed binary content, rejected read modes and conversion cancellation preserve existing worksheet objects, filename, source format and source archive binding
After validated binary conversion enters the existing XML parser, late XML parsing or application callback failures follow the ordinary XML open lifecycle; the preflight guarantee does not promise rollback of arbitrary callback writes
Saving stages the entire binary package; file output uses a sibling temporary file and one final replacement, and readable seekable stream output retains a byte, size and position snapshot for rollback after a commit failure
LastSaveUsedStreaming=False reflects complete binary staging even when the intermediate XML writer streams; memory includes converted parts and the complete package, so this backend is not a bounded-memory streaming writer
Conversion reports and preflight retain packed cell storage, including a mixture of packed values and materialized formulas; successful saving can expand packed values through the existing style preparation and worksheet writer, so report purity does not imply an immutable or nonmaterializing save operation
Successful binary file saving clears previous raw XML source bindings; stream saving retains filename behavior, and cancellation is checked before destination commit
Package conversion APIs
procedure XlsbToOpenXml(Source: TZipArchive; Destination: TStream; CancelCheck: TXLSStreamCancelCheck = nil; EntryCompressionLevel: Integer = -1; EntryFixedDate: TDateTime = 0); procedure OpenXmlToXlsb(Source: TZipArchive; Destination: TStream; CancelCheck: TXLSStreamCancelCheck = nil; EntryCompressionLevel: Integer = -1; EntryFixedDate: TDateTime = 0); function XlsbStylesToXml(const Data: AnsiString): AnsiString; function XlsbStylesFromXml(const Data: AnsiString): AnsiString; function XlsbStringsToXml(const Data: AnsiString): AnsiString; function XlsbStringsFromXml(const Data: AnsiString): AnsiString;
TXlsbFormulaValidator.Create(WorkbookXml) validates the workbook name context and Validate(FormulaText, SheetIndex) validates a formula without worksheet cell access; SheetIndex is zero-based and the caller owns the validator
XlsbValidateTableXml(Data) and XlsbValidateAutoFilterXml(Data) validate UTF-8 object XML against the same encoder contracts used by package output; failures raise the existing format or unsupported-feature exceptions
These lxXlsb APIs retain caller ownership; package conversion validates and stages all parts before replacing Destination from offset zero, and core-part bridges use UTF-8 XML and raw binary bytes
EXlsbUnsupported derives from EXlsbFormatError and distinguishes expected subset rejection from malformed data; cancellation raises the established stream cancellation exception before commit
Compression accepts -1 through 9, and the fixed date accepts zero or a finite DOS-representable date from 1980 through 2107; invalid options reject before destination changes