XLSB
XLSB is Excel's binary workbook format. This page lists what a save to .xlsb writes from the model, what it keeps as stored, and what it leaves out or refuses.
XLSB shares the workbook model with XLSX, but its writer does not emit everything the model holds. Save with diagnostics to see what was left out:
import createFormulon, { WorkbookFormat } from '@libraz/formulon'
const formulon = await createFormulon()
using wb = formulon.Workbook.createDefault()
const ws = wb.sheet(0)
ws.setValue('A1', 42)
console.log(wb.saveWithDiagnostics(WorkbookFormat.Xlsb).deferredFeatureCount) // 0
// A custom style usable by neither tables nor PivotTables: the XLSB writer leaves it out.
wb.setTableStyle({ name: 'Ledger', table: false, pivot: false })
const out = wb.saveWithDiagnostics(WorkbookFormat.Xlsb)
console.log(out.deferredFeatureCount, out.downgradedFormulaCount) // 1 0from formulon import TableStyle, Workbook, WorkbookFormat
with Workbook.create_default() as wb:
ws = wb[0]
ws["A1"] = 42
print(wb.save_with_diagnostics(format=WorkbookFormat.XLSB).deferred_feature_count) # 0
# A custom style usable by neither tables nor PivotTables: the XLSB writer leaves it out.
wb.set_table_style(TableStyle(name="Ledger", table=False, pivot=False))
out = wb.save_with_diagnostics(format=WorkbookFormat.XLSB)
print(out.deferred_feature_count, out.downgraded_formula_count) # 1 0deferredFeatureCount counts features the XLSB writer did not emit; a new workbook of any profile saves with none.
An XLSX save counts in it too:
- each PivotTable of an XLSB source the reader could not read;
- each custom view of an XLSB source with no XLSX form;
- each macro name of an XLSB source (a workbook without a macro sheet cannot hold one in XLSX, so it is left out as Excel leaves it out);
- each print record family of an XLSB sheet (print options, margins, page setup, header/footer, row breaks, column breaks) whose stored records the model cannot state exactly.
Both formats count rich values kept as stored once, when a rich error in the workbook is saved as a plain error or their metadata part is left out, and each drawing adjust guide a save leaves out because the shape's preset does not define it or it repeats an earlier one, since Excel refuses to open a file that holds one; a guide on a preset that defines none is left out uncounted, as Excel leaves it out.
downgradedFormulaCount counts formulas written as cached literals because they have no XLSB token encoding.
Worksheet records loaded from XLSB that the model does not hold, such as table references and print records the model cannot state exactly, and any drawing the reader cannot lift into the model, are kept verbatim with their relationships. An AutoFilter loaded from XLSB is read into the model and is visible to the typed API; one the model could not write back whole is kept as stored.
PivotTables and their caches loaded from XLSB are read into the model like those of an XLSX file, so they can be inspected, edited and refreshed, and an XLSX save keeps them; one the reader cannot read stays as stored. The table lists the current behavior feature by feature.
| XLSB feature | Current behavior |
|---|---|
Styles (BrtFmt / BrtXF) and differential formats (BrtDXF) | modeled and emitted; loading decodes BrtDXF, so conditional-format rules keep a resolvable dxfIndex and converting .xlsb to .xlsx keeps their formatting. An unedited styles table is written byte for byte, and after a style edit such as addDxf() the styles part is regenerated from the model. Named cell styles load from .xlsb and keep their names through an .xlsb or .xlsx save |
| Row/column layout, merges | modeled and emitted |
Workbook properties (BrtWbProp, including date1904) and calculation settings (BrtCalcProp) | modeled and emitted, so manual calculation and iteration survive a save. The settings Excel itself drops from an .xlsb save (workbookPr dateCompatibility and allowRefreshQuery, an attribute of another namespace, a window's extension list, metadata types the workbook does not use) are left out without a report; an unknown attribute without a namespace is reported |
| Sheet views, zoom, frozen and split panes, selections | modeled and emitted: panes, selections, every workbook window and the sheet views of extra windows (details) |
| Custom views (View > Custom Views) | kept across an XLSB resave, and across a save between .xlsx and .xlsb in either direction (details) |
| Gradient fills, dxf font outline / shadow / condense / extend | modeled and emitted (BrtFill, BrtDXF) |
| Dynamic-array metadata and supported tokenized formulas | modeled and emitted |
| Pivot caches and PivotTables | read into the model on load; one the reader cannot read stays as stored (details) |
| Conditional formatting | modeled and emitted; supported predicates are evaluated and visual payloads, including x14 data bars and custom icon sets (BrtCFIcon), are retained. Formula thresholds are written; a threshold whose formula names a defined name of another workbook fails the save with StatusCode.InvalidArgument. The legacy copy Excel adds beside an x14 rule loads as one rule |
| Data validation | modeled and emitted, including the input-method mode; explicit proposed-value and stored-cell checks are available, without automatic mutation or enforcement |
| Scenarios, cell watches and ignored-error markers | kept through a save and converted between .xlsx and .xlsb in both directions; an .xlsx element carrying a setting the records cannot hold is left out of an .xlsb save |
| Sheet/workbook protection | modeled and emitted as metadata, including lockWindows, lockRevision and the revisions password (BrtBookProtection, BrtBookProtectionIso) and protected ranges (BrtRangeProtection); the engine does not enforce cell locks (details) |
| AutoFilter and sort state | modeled and emitted for each sheet, read into the model on load; the sheet's filter mode follows its criteria (details) |
| Hyperlinks | modeled and emitted from the workbook model |
| Drawing and table references, and relationships | preserved verbatim when unmodeled; compatible retained tails may pass through |
| Classic notes, their drawing, threaded comments and persons | modeled and emitted for each sheet, and read into the model on load; a note's formatted runs keep their fonts. A note without a revision id gets the one Excel assigns, built from the sheet's tab position and the note's place among that sheet's notes. A note created through the API has no revision id; editing a loaded note keeps its id. |
| OOXML drawings: pictures, charts, and shapes | written with a sheet relationship and a drawing record; a drawing that also holds slicer frames, SmartArt, or other non-chart graphic frames is not linked and is reported once per sheet. A drawing loaded from XLSB is editable like an XLSX drawing; one the reader cannot lift is retained verbatim and passes through |
| Print options, page margins, page setup, header/footer, manual page breaks | emitted from the model for a workbook loaded from .xlsx or built through the API (details) |
| Tables and structured references | modeled and emitted (BrtBeginList with style, flags, totals, calculated columns, AutoFilter and sort state; PtgList); a table setting the records cannot hold is reported |
| What-If data tables | emitted as BrtTable ahead of the anchor cell's value record, with the always-calculate flag |
| Sparkline groups | read, listed and edited the same way as from XLSX, and written; a source or date range loaded from .xlsx that is a union, a structured reference or an expression fails the save with StatusCode.IoFeatureNotWritable |
| Table slicers | kept across an XLSB resave; those from an XLSX source are not written and are reported |
| Custom table and PivotTable styles, default style names | modeled and emitted with the differential formats their elements use, and read on load; a style usable by neither tables nor PivotTables is left out and reported |
| Unrepresentable sheet defaults | a default column width, base width or row height Excel cannot hold is written as the format's default and reported; an outline level of 8 or more is written as 7, as in .xlsx |
| Unsupported formulas | may downgrade to cached literals; downgrade count is reported. A formula whose sheet qualifier names no sheet of the workbook, such as =Nope!A1 or =SUM(Data:Nope!A1), is written as its cached value alone, while an .xlsx save keeps the formula text |
A nonzero deferredFeatureCount after a save means the XLSB differs from the model. A feature the XLSB writer cannot write at all fails the whole save instead: save and saveWithDiagnostics (Python save and save_with_diagnostics, raised as IoError) throw StatusCode.IoFeatureNotWritable, nothing is written, and the error's context names the feature with kind= and, for a sheet-scoped one, the sheet with sheet_index=.
The CLI's recalc -o to an .xlsb path exits with status 1 in the same case. Both containers keep the source file's sheet ids instead of renumbering them by position.
Print area and print titles are defined names and are emitted to XLSB. Do not infer pivot preservation from the tail-preservation rule. Keep a source workbook and verify the emitted package when those features matter.
Details by feature
Sheet views
- Panes are written as
BrtPanewith the column split first, oneBrtSelselection per pane, every workbook window (BrtBookView) and the sheet views of extra windows. - A view's extension list is left out, as Excel leaves it.
- A view of a window the workbook does not have is read and written with its window id as stored.
- A second view of the first window beside its main view is left out and reported.
- A view with an unknown view mode is written as normal and reported, and read as normal on load.
Custom views
- Custom views are kept across an XLSB resave, and across a save from
.xlsxto.xlsbor from.xlsbto.xlsx, each workbook view written as Excel writes it together with every sheet's view of it. - A sheet custom view's margins, print options, header/footer, page breaks and filter stay with the view and are not read as the sheet's own.
- A view the other format cannot hold is left out together with its sheet views: a view whose AutoFilter the other format cannot state exactly, and, going from
.xlsbto.xlsx, a view holding an automatic page break. - A save to either format reports each view it leaves out in
deferredFeatureCount, and an.xlsbsave also reports a workbook view no saved sheet still carries.
Pivot caches and PivotTables
- Both are read into the model on load. One the reader cannot read stays as stored: an XLSB save keeps it, and an XLSX save leaves it out and reports it.
- A save writes an unchanged PivotTable loaded from XLSB as Excel saved it, and one loaded from XLSX, built through the API, edited or refreshed from the model, with Excel's Windows or Mac records for the workbook's profile.
- A source cell left blank is written as Excel writes it, whether or not its cache field has shared items.
- A PivotTable with a feature the engine does not write to XLSB yet, such as a PivotChart over it (list), is left out together with its cache and the other PivotTables on that cache, and reported; the rest of the save succeeds.
Sheet and workbook protection
- A security descriptor read from
.xlsbis written back as read. - A range of more than 8,191 rectangles, which only a loaded file can carry, is read from and written to a
BrtRangeProtection14record as Excel writes it. - A security descriptor Excel can encode is saved in the record.
- A range with any other security descriptor text, a name outside 1 to 255 UTF-16 units, a range that cannot be parsed, or more than 8,191 rectangles together with a modern password hash, which that record cannot hold, fails the save with
StatusCode.IoFeatureNotWritable, its context namingkind=protected_range_descriptor,kind=protected_range_title,kind=protected_range_sqreforkind=protected_range_rects. - A protected-range record that cannot be decoded is skipped on load and counted in
skippedFeatureCount.
AutoFilter and sort state
- A date-group criterion in the rich-data form Excel gives a date filter it creates, and a top-ten or dynamic criterion without the bounds Excel computed when it last applied the filter, are left out and reported.
- A colour criterion without a format is left out, as Excel leaves it out.
- A value filter keeps its values under any calendar type, and a blank custom criterion (
equal "") survives a load and a save. - A loaded filter that cannot be written back whole is kept as stored.
Print settings
- Page setup keeps paper size, scale, resolution, copies, first page number, page order, orientation, black and white, draft, comments and error printing, and automatic breaks are left out, as Excel leaves them out.
- The sheet properties record carries fit-to-page and the outline settings. Other
<sheetPr>settings and a printer-settings part are reported. - A page setup and margins loaded from XLSB are read into the model as their XLSX twin carries them, so
getPageSetup()andgetPageMargins()report them and an.xlsxsave keeps them, while the margins and print options of a custom view stay with that view. A page setup that refers to printer settings, or carries a setting Formulon does not read, stays verbatim and reads as the defaults. - A header/footer and manual page breaks loaded from XLSB are read into the model the same way, so
getHeaderFooter()andlistRowBreaks()report them and an.xlsxsave keeps them; one whose records the model would not write back exactly stays verbatim. - Print options loaded from XLSB are read into the model when the writer writes back exactly the stored record, so
getPrintOptions()reports them and an.xlsxsave keeps grid lines and headings as Excel states them; otherwise they stay verbatim. - An
.xlsxsave counts indeferredFeatureCounteach of these record families whose stored records the model cannot state exactly; print options all at their defaults are not counted, and an.xlsbsave keeps every family.