XLSB keeps the model of XLSX (a sheet has up to 1,048,576 rows and 16,384 columns) but stores it in records that are close relatives of the BIFF8 ones, with wider row and column numbers and UTF-16 text everywhere. Record numbers are decimal; sections refer to [MS-XLSB].
The workbook part
xl/workbook.bin runs from BrtBeginBook (131) to
BrtEndBook (132): BrtFileVersion (128, the application name
and versions that last edited the file), workbook properties, views, then the sheet
list between BrtBeginBundleShs (143) and BrtEndBundleShs
(144). Each sheet is a BrtBundleSh (156):
| Field | Size | Meaning |
|---|---|---|
hsState | 4 | 0 visible, 1 hidden, 2 very hidden. |
iTabID | 4 | Unique sheet id. |
strRelID | varies | Relationship id of the sheet’s part, such as rId1 (RelID: an XLWideString). |
strName | varies | Sheet name, XLWideString. |
A worksheet part
A worksheet runs from BrtBeginSheet (129) to BrtEndSheet
(130). Near the start, BrtWsDim (148) gives the used range as four
4-byte values: first row, last row, first column, last column. The cells come between
BrtBeginSheetData (145) and BrtEndSheetData (146): for each
row a BrtRowHdr (0), then that row’s cell records in column order.
Columns, merged cells, conditional formats, hyperlinks, page setup and the rest follow.
BrtRowHdr (0)
| Field | Size | Meaning |
|---|---|---|
rw | 4 | Row, from 0. |
ixfe | 4 | Row format (BrtXF index). |
miyRw | 2 | Height in twips. |
| flags | 3 | fExtraAsc, fExtraDsc (extra space above, below), outline level (3 bits), fCollapsed, fDyZero (hidden), fUnsynced (height set by hand), fGhostDirty (row format applies), fPhShow (show phonetic guides). |
ccolspan | 4 | Number of column spans that follow (up to 16). |
rgBrtColspan | 8 each | First and last column (4 bytes each) of each run of cells in the row. |
Cell records
Every cell record starts with an 8-byte Cell structure (2.5.10): the column (4
bytes), then 24 bits of style (index into the BrtXF cell formats), a bit
fPhShow and 7 reserved bits. The row is the last BrtRowHdr’s.
| Type | Record | After the Cell |
|---|---|---|
| 1 | BrtCellBlank | Nothing: a formatted empty cell. |
| 2 | BrtCellRk | 4-byte RK number (below). |
| 3 | BrtCellError | 1-byte error code (below). |
| 4 | BrtCellBool | 1 byte, 0 false or 1 true. |
| 5 | BrtCellReal | 8-byte IEEE double. |
| 6 | BrtCellSt | The text itself, XLWideString. |
| 7 | BrtCellIsst | 4-byte index into the shared string table. |
| 8 | BrtFmlaString | Cached text result (XLWideString), 2 flag bytes, formula. |
| 9 | BrtFmlaNum | Cached number (8-byte double), 2 flag bytes, formula. |
| 10 | BrtFmlaBool | Cached Boolean (1 byte), 2 flag bytes, formula. |
| 11 | BrtFmlaError | Cached error code (1 byte), 2 flag bytes, formula. |
| 62 | BrtCellRString | Rich text (RichStr); used in revision logs. |
In the formula records the 2 flag bytes (GrbitFmla) hold fAlwaysCalc in
bit 1. Shared formulas, array formulas and data tables are stored once in
BrtShrFmla (427), BrtArrFmla (426) and
BrtTable (428).
RK numbers (2.5.123) are packed exactly as in BIFF8: bit 0 means
divide by 100, bit 1 means bits 2–31 are a signed integer, otherwise they are the top
30 bits of a double. Error codes (BErr): 0x00
#NULL!, 0x07 #DIV/0!, 0x0F
#VALUE!, 0x17 #REF!, 0x1D
#NAME?, 0x24 #NUM!, 0x2A
#N/A, 0x2B #GETTING_DATA.
Strings
- XLWideString (2.5.169): a 4-byte character count, then that many UTF-16LE code units. There is no compressed 8-bit form.
- RichStr (2.5.122): a flags byte (bit 0
fRichStr, bit 1fExtStr), the text as an XLWideString, then iffRichStra 4-byte run count and 4-byte runs (character index 2, BrtFont index 2), and iffExtStrthe phonetic text (XLWideString), a 4-byte count and 8-byte phonetic runs (first phonetic character, first base character, base character count, font index; 2 bytes each). - The Shared Strings part runs from
BrtBeginSst(159, holding the total number of references and the number of unique strings, 4 bytes each) through oneBrtSSTItem(19, a RichStr) per string toBrtEndSst(160).BrtCellIsstcells index into it from 0.
Formulas
A cell formula (CellParsedFormula, 2.5.98.4) is a 4-byte length, the tokens
(Rgce), a 4-byte length and the extra data (RgbExtra). The tokens use the same Ptg
codes and operand classes as BIFF8,
with wider fields: a cell reference (RgceLoc) is a 4-byte row and a 2-byte column
whose bits 0–13 are the column and bits 14 and 15 the column-relative and
row-relative flags; a range (RgceArea) is two 4-byte rows and two 2-byte columns, so
PtgRef carries 6 bytes and PtgArea 12; PtgStr holds a 2-byte count and UTF-16 text.
The function numbers (Ftab, Cetab) are BIFF8’s, plus these added in XLSB (2.5.98.10):
017C CUBEVALUE, 017D CUBEMEMBER, 017E CUBEMEMBERPROPERTY, 017F CUBERANKEDMEMBER, 0180 HEX2BIN, 0181 HEX2DEC, 0182 HEX2OCT, 0183 DEC2BIN, 0184 DEC2HEX, 0185 DEC2OCT, 0186 OCT2BIN, 0187 OCT2HEX, 0188 OCT2DEC, 0189 BIN2DEC, 018A BIN2OCT, 018B BIN2HEX, 018C IMSUB, 018D IMDIV, 018E IMPOWER, 018F IMABS, 0190 IMSQRT, 0191 IMLN, 0192 IMLOG2, 0193 IMLOG10, 0194 IMSIN, 0195 IMCOS, 0196 IMEXP, 0197 IMARGUMENT, 0198 IMCONJUGATE, 0199 IMAGINARY, 019A IMREAL, 019B COMPLEX, 019C IMSUM, 019D IMPRODUCT, 019E SERIESSUM, 019F FACTDOUBLE, 01A0 SQRTPI, 01A1 QUOTIENT, 01A2 DELTA, 01A3 GESTEP, 01A4 ISEVEN, 01A5 ISODD, 01A6 MROUND, 01A7 ERF, 01A8 ERFC, 01A9 BESSELJ, 01AA BESSELK, 01AB BESSELY, 01AC BESSELI, 01AD XIRR, 01AE XNPV, 01AF PRICEMAT, 01B0 YIELDMAT, 01B1 INTRATE, 01B2 RECEIVED, 01B3 DISC, 01B4 PRICEDISC, 01B5 YIELDDISC, 01B6 TBILLEQ, 01B7 TBILLPRICE, 01B8 TBILLYIELD, 01B9 PRICE, 01BA YIELD, 01BB DOLLARDE, 01BC DOLLARFR, 01BD NOMINAL, 01BE EFFECT, 01BF CUMPRINC, 01C0 CUMIPMT, 01C1 EDATE, 01C2 EOMONTH, 01C3 YEARFRAC, 01C4 COUPDAYBS, 01C5 COUPDAYS, 01C6 COUPDAYSNC, 01C7 COUPNCD, 01C8 COUPNUM, 01C9 COUPPCD, 01CA DURATION, 01CB MDURATION, 01CC ODDLPRICE, 01CD ODDLYIELD, 01CE ODDFPRICE, 01CF ODDFYIELD, 01D0 RANDBETWEEN, 01D1 WEEKNUM, 01D2 AMORDEGRC, 01D3 AMORLINC, 01D5 ACCRINT, 01D6 ACCRINTM, 01D7 WORKDAY, 01D8 NETWORKDAYS, 01D9 GCD, 01DA MULTINOMIAL, 01DB LCM, 01DC FVSCHEDULE, 01DD CUBEKPIMEMBER, 01DE CUBESET, 01DF CUBESETCOUNT, 01E0 IFERROR, 01E1 COUNTIFS, 01E2 SUMIFS, 01E3 AVERAGEIF, 01E4 AVERAGEIFS. Later functions are called by name through number 00FF.