Introduction
XLSB is a binary workbook format of Microsoft Excel, introduced with Excel 2007 alongside XLSX. It holds the same workbook as XLSX in the same kind of package, but writes each part as compact binary records instead of XML. Large workbooks open and save faster and take less space, which is why some people use it for big data sets. It can hold macros.
Microsoft publishes the format in full as [MS-XLSB].
Structure
An XLSB file is a ZIP package following the Open
Packaging Conventions, laid out like XLSX, but its parts end in .bin:
xl/workbook.bin, xl/worksheets/sheet1.bin,
xl/sharedStrings.bin and xl/styles.bin
(package and parts). Each part is a
sequence of records, each a record
type and a size, both written as variable-length numbers, followed by the data
(cells, strings and formulas). Some parts, such as the content types, relationships and
document properties, stay XML.
Key programs and divergence from the standard
- Microsoft Excel, the writer of every file in the test set below and the reference for [MS-XLSB];
- LibreOffice Calc, which reads
.xlsband can save the same workbook as.xlsx; the styles of 23 sample files were compared with that copy; - Apache POI (
XSSFbinary reader, test files such asSimple.xlsb) and ExcelDataReader (its test data, MIT licence, supplied 16 of the files).
Divergence from spec
| Where | The standard says | Programs do |
|---|---|---|
| BrtBorder and Blxf (2.4.314, 2.5.5) | one byte of flags (fBdrDiagDown, fBdrDiagUp, six reserved bits), then five Blxf of 10 bytes: top, bottom, left, right, diagonal | Excel files follow this exactly; the viewer reads the five edges at offsets 1, 11, 21, 31 and 41 (the packet diagram can be misread as a 2-byte flag field) |
| Border shared by two cells | each cell has its own four edges | LibreOffice keeps a shared edge on one of the two cells when it writes .xlsx, and draws the borders of a merged range on every cell inside it; the viewer compares borders as grid edges for that reason |
| Colour with automatic type | BrtColor with xColorType 0 is automatic | LibreOffice writes no colour element for it; the viewer shows it as the default (automatic) |
| Hyperlink cells and single-run rich text | the cell keeps its own font and the run keeps its own | LibreOffice applies its hyperlink character style to link cells and moves the format of a lone run into the cell font; the viewer keeps what the file says |
| BrtBeginCustomFilters (2.4.40), fAnd | the value table says 0 means AND and 1 means OR, while the field is named fAnd | LibreOffice reads 0 as AND, as the table does, and the viewer follows it; the name suggests the opposite |
| BrtBeginIconSet (2.4.91), fReverse | the text for fReverse reads the wrong way round | the viewer reads the bit set as reversed icons, which agrees with an Excel-written file saved from an .xlsx with reverse="1" (the icon-only bit agrees too); LibreOffice reads the reverse flag only from .xlsx attributes, not from the binary record |
| BrtBeginIconSet14 (2.4.92), fReverse | 0 means the icons of the set are shown in reverse order, 1 means the order of the set | Excel writes the bit set for reversed icons and clear otherwise (checked on an Excel-written file saved from an .xlsx with reverse="1" and one without); the viewer reads the bit that way, not as the table says |
| Data validation of the type "any" | BrtDVal valType 0 is any value | LibreOffice writes the type as "none" in .xlsx and fills the operator, blank flag and formulas with its own defaults, so those are compared only for the other types |
| BrtBeginPCDSRange (2.4.167), fName | when fName is 1 the source is a defined name | Excel also writes an Excel table name there (pivot-position.xlsb: SalesData); the viewer looks for a defined name first, then a table of that name |
| Pivot table location | BrtBeginPivotTableRef / location stores the range of the table | LibreOffice recomputes it (A3:C9 where Excel stored A3:C8); the viewer shows what the file says |
| x14 conditional formatting on Save As | BrtBeginDatabar14 and its BrtColor14 records hold the extended data bar | Excel dropped the x14 data bar properties of one .xlsx (cfx14.xlsx) when it saved it as .xlsb, keeping only the classic data bar; other files kept them |
| Revision headers | one BrtRRHeader per revision log | Excel wrote a headers part that repeats the same two BrtRRHeader records (the original log and a second one with a custom view added by the save) when it converted a file that had one log; the viewer lists every record, so each header appears twice |
| Cell records in a revision log (2.4.774 and the cell records of 2.4.1) | a changed cell is an ordinary cell record, with the layouts of the worksheet | Excel writes a formula cell of any result type (text, boolean, error as well as number) as BrtFmlaNum (id 9) with the number 0, with the number straight after the column (no style field) and six bytes before the formula length, and writes a text cell as BrtCellRString (id 62, an extra flag byte before the string); the viewer reads those layouts inside revision logs only |
| BrtDXF number format (XFProp 0x0026) in a revision log | [MS-XLS] 2.5.126 XLUnicodeString: character count (2), a flag byte, then the characters | Excel writes the count (2) and the UTF-16 characters with no flag byte inside a revision log (shared-tracked-3.xlsb: 0.00); the viewer takes the form whose length fits the property size |
Not described
[MS-XLSB] documents every record, and every record is decoded here. What is not covered is listed below; nothing else is left.
Coverage notes
- Reference: the field layouts of the records outside the cells and formulas and outside the workbook records and the styles part (BrtFont, BrtXF, BrtFill, BrtBorder, BrtDXF, BrtColor, the table styles and the colour palettes are decoded field by field, see the viewer): worksheet settings, formatting and validation, tables and filters, external links, connections, PivotCache, PivotTable, slicers, comments and metadata, and revisions. The record list gives their numbers and names only.
- Viewer: the explorer opens
.xlsbfiles: it lists the package parts, reads every record of every binary part (record numbers and names from [MS-XLSB] 2.3.2, 877 types; a number the specification does not list is shown as unknown with its bytes, never dropped), and shows the sheets as tables of formatted values, with the cells (BrtRowHdr, BrtCellBlank, Rk, Error, Bool, Real, St, Isst, BrtFmla*), shared strings, the number formats, fonts and XFs of the styles part, the sheets and defined names of the workbook, merged cells, hyperlinks, column widths, array and shared formulas and the formulas themselves (the Rgce tokens of 2.5.98.88 decoded to the text Excel shows, with the function names of the Ftab table), the same overview, formula, features and styles tabs as XLSX, the VBA project (listed, never run), and the XML parts (theme, drawings, charts). - Viewer: the styles part is decoded in full: fonts (with colour, scheme, condense and extend), fills (pattern and gradient), borders, XFs (alignment, reading order, protection, the applied groups), differential formats (BrtDXF with every XFProp), indexed and recently used colours, and table styles; colours (BrtColor: automatic, index, RGB, theme with tint) are checked against LibreOffice's reading of the same files (parser-test/test-xlsb-styles.mjs, 23 files, 42,402 cells: font, fill, border edges and alignment agree).
- Viewer: the sheet features are decoded into the same features tab as XLSX: comments (author, cell, text),
data validation (BrtDVal), conditional formatting (cell value, text, top and bottom, average, colour scale, data bar and
icon set rules, with their thresholds and colours), the AutoFilter of a sheet and of a table (value lists, date groups,
custom, top ten, dynamic, colour and icon filters) and sort states, and the tables (BrtBeginList with its columns, calculated
column and total row formulas, and the table style); a formula's table references (PtgList) are shown as Excel writes
them, for example
Sales[[#Headers],[Qty]], and a pivot name (PtgSxName) as its number. Comments (15) and data validations (60) agree with LibreOffice's reading of the 57 sample files; the sample files hold no conditional formatting, filters, sort states or tables, so those are checked only against byte strings built from the field layouts of the specification (parser-test/test-xlsb-sheets.mjs). - Viewer: decoded into the features tab: pivot caches (definition, source, fields, record count) and pivot tables (location, cache, field counts),
query tables with their fields, the cached cells and sheet and defined names of external links (and the DDE and OLE links), the
metadata part (types, formula metadata, dynamic-array flags), extended (x14) conditional formatting (icon sets, data bars, colour scales and rules,
2.4.24, 2.4.335, 2.4.391, with the FRTHeader of 2.5.61) (with data bar direction, axis and border, and BrtCFIcon custom icons, 2.4.332), the macro-function names of the Cetab table (2.5.98.5) and the shared-workbook revisions: the headers part (BrtRRHeader, 2.4.782; user, date, revision range) and the revision log parts (row and column insert and delete, moves, cell changes, sheet insert and rename; sections 2.1.7.43, 2.1.7.44 and 2.2.12). Each revision shows its decoded fields. These decoders are checked against Excel-written
.xlsbfiles, made by saving real.xlsxfiles from other projects with Excel's Save As (the files are in samples/xlsb/excel-converted): pivot caches and tables (a worksheet-range, table-name and external source; counts, locations and record counts agree with the originals and with LibreOffice), query tables and their connection, x14 data bars (lengths, gradient, rule GUID, the five BrtColor14 colours in the order and conditions of 2.4.44, automatic minimum and maximum of 2.5.20), classic cell-value rules, and a revision header with its log (users, dates, revision numbers and the changed cell). The external link and metadata parts are checked against one Excel-written file. x14 icon sets are checked the same way (3Stars, 3Triangles, 5Boxes, a custom set with BrtCFIcon icons, the icon-only and reverse bits, all twenty KPISets14 names of 2.5.87 covered); colour scales have no x14 form and the classic BrtBeginColorScale is checked against Excel-written files and LibreOffice. Where an Excel-written file was made by editing an.xlsxfirst (to add a rule Excel then saved), the sample says so in its name. The old and new cell values (BrtRRChgCell, 2.4.774, with the cell records that follow it and the SqEtxp font count of 2.5.138), defined names (BrtRRDefName, 2.4.776, with RRdDnGrbit, 2.5.125), comments (BrtRRNote, 2.4.786), custom views (BrtRRUserView, 2.4.790), conflicts (BrtRRConflict, 2.4.775), query-table field removal (BrtRRTQSIF, 2.4.789), formatting (BrtRRFormat, 2.4.781) and AutoFormat (BrtRRAutoFmt, 2.4.773) are decoded field by field from those sections. Of these, the header, row and column insert and delete, move, cell-change (old and new numbers, text and formulas), sheet insert, sheet rename, format, defined-name and custom-view records have been compared with Excel-written files (shared-tracked.xlsb and shared-tracked-2.xlsb, saved from the same shared workbook whose.xlsxlog lists the same changes); four record types are byte-built only, checked against byte strings made from the specification layouts and never against an Excel-written file: BrtRRNote (2.4.786), BrtRRConflict (2.4.775), BrtRRTQSIF (2.4.789) and BrtRRAutoFmt (2.4.773). Excel for Mac wrote none of them: two comments added to a shared workbook went only to the comments part, and a conflict cannot be made with one user. Strings, booleans and errors as old and new formula results were not seen either: Excel writes every formula as BrtFmlaNum. Not described: the Calculation Chain part is shown as records only, since the specification calls it an application-specific cache and defines no records for it; the number-format limits of the XLSX page apply. - Reference: [MS-XLSB] v20261118 was read as text (research/xlsb/MS-XLSB.txt); the record and function tables of the viewer are typed from its sections 2.3.2 and 2.5.98.10 and checked against that text. Two rows of the Ftab table (0x0075 EXACT and 0x00D3 LENB) carry the parameter grammar of another function, so the viewer uses the real fixed counts (2 and 1); one real file (Apache POI's Simple.xlsb) has four extra bytes in its BrtBundleSh records, which the viewer reads around and reports.
Links
Software
- Microsoft Excel – Microsoft’s spreadsheet, which opens and saves XLSB (Windows, macOS)
- LibreOffice Calc – free office suite’s spreadsheet, which opens XLSB (Windows, macOS, Linux)
Developers
Reference
- [MS-XLSB]: Excel (.xlsb) Binary File Format – Microsoft’s full specification of the format