Microsoft specifies BIFF8 in full as [MS-XLS], Excel Binary File Format (.xls) Structure (revision 12.2, 19 August 2025, used for this page). Section numbers below refer to it. All numbers are little-endian.
The compound file
An .xls file is an OLE compound file ([MS-CFB]), which starts with
D0 CF 11 E0 A1 B1 1A E1 and holds a small file system of storages and
streams (section 2.1.1). The compound file itself is described on the
Word 97 container page.
Section 2.1.7 lists the streams an Excel file may contain:
| Stream or storage | Contents |
|---|---|
Workbook | Required. The workbook data as records (below). |
\005SummaryInformation, \005DocumentSummaryInformation | Document properties (title, author and so on). |
\001CompObj | The OLE class of the document. |
_VBA_PROJECT_CUR | Storage holding the VBA macro project. |
Ctls | ActiveX control data. |
MBD… storages, LNK… storages, \001Ole | Embedded and linked OLE objects. |
_SX_DB_CUR | PivotTable caches. |
Revision Log, User Names | Shared-workbook change history and users. |
List Data | Data of lists (tables) in a shared workbook. |
XML, MsoDataStore, XCB | XML maps, custom data and toolbars. |
_signatures, _xmlsignatures | Digital signatures. |
\006DataSpaces, \009DRMContent, \009DRMViewerContent, encryption | Rights-managed and encrypted content. |
(\005 and similar stand for the control character at the start of the
stream name.)
Records
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 2 | type | Record type, from the record list. |
2 | 2 | size | Length of the data, 0 to 8,224 bytes. |
4 | size | data | Fields of that record type. |
Data longer than 8,224 bytes is split: the first 8,224 bytes stay in the record and
the rest follows in Continue records (type 0x003C) of up to
8,224 bytes each, or ContinueFrt, ContinueFrt11,
ContinueFrt12, ContinueBigName and
CrtMlFrtContinue for particular records (sections 2.1.4 and 2.4.58).
Some records use Continue even when short; for example a text box’s
TxO keeps its text and formatting runs in following Continue records.
Strings split across a Continue record start the continuation with a fresh option
byte (see Strings).
Records with type 2048 to 2303 (0x0800–0x08FF) in chart
sheets, and records carrying an FrtHeader, are future records:
a program that does not understand them is expected to keep them unchanged when it
saves (section 2.1.6).
Substreams
The Workbook stream is a series of substreams, each from a BOF record
to an EOF record (type 0x000A, no data). The first is the
globals substream; then come one or more sheet substreams, in the order of the
BoundSheet8 records (section 2.1.7.20).
0GlobalsBOF(dt 5), file protection,CodePage,Window1,Font,Format,XF,Style,BoundSheet8per sheet, names,SST,ExtSST,EOFrecords…WorksheetBOF(dt 16), settings,Index,Dimensions, rows and cells in blocks withDBCell, drawing and objects,Window2,EOFrecords…Chart sheet (dt 32), macro sheet (dt 64) or dialog sheet (dt 16 withWsBool.fDialog)records
Record order of each substream
[MS-XLS] 2.1.7.20.1 to 2.1.7.20.6 give the record order of each substream as ABNF
([RFC5234]). A name in capitals is a production, a name in mixed case a record, [x]
an optional item, *x zero or more, 1*x one or more,
1*510x one to 510 and / a choice. Every production but the
top ones is spelled out here exactly as the specification has it; the chart sheet
(2.1.7.20.1) is on the charts page,
the pivot productions (PIVOTVIEW to PIVOTADDL) on the
PivotTables and
SXAddl pages and the
revision productions on the revisions page.
Globals substream (2.1.7.20.3)
Exactly one, and the first in the Workbook stream.
WORKBOOK = BOF WORKBOOKCONTENT
WORKBOOKCONTENT = [WriteProtect] [FilePass] [Template] INTERFACE WriteAccess [FileSharing]
CodePage *2047Lel DSF [Excel9File] RRTabId [ObProj] [ObNoMacros] [CodeName] [FNGROUPS]
*Lbl [OleObjectSize] PROTECTION 1*Window1 Backup HideObj Date1904 CalcPrecision
RefreshAll BookBool FORMATTING *(PIVOTCACHEDEFINITION) [DOCROUTE] *UserBView UsesELFs
1*BUNDLESHEET METADATA [MTRSettings] [ForceFullCalculation] Country *SUPBOOK *LBL *RTD
[RecalcId] *HFPicture *MSODRAWINGGROUP [SHAREDSTRINGS] ExtSst *WebPub [WOpt] [CrErr]
[BookExt] *FeatHdr *DConn [THEME] [CompressPictures] [Compat12] [GUIDTypeLib] EOF
INTERFACE = InterfaceHdr Mms InterfaceEnd
FNGROUPS = BuiltInFnGroupCount *FnGroupName *FnGrp12
PROTECTION = WinProtect Protect Password Prot4Rev Prot4RevPass
FORMATTING = 1*510Font 8*218Format XFS *DXF STYLES [TABLESTYLES] [Palette] [ClrtClient]
XFS = 16*XF [XFCRC 16*4050XFExt]
STYLES = 1*(Style [StyleExt])
TABLESTYLES = TableStyles *(TableStyle *28TableStyleElement)
PIVOTCACHEDEFINITION = SXStreamID SXVS [SXSRC] [SXADDLCACHE]
SXSRC = DREF / SXTBL / DBQUERY
DREF = DConName / DConBin / DConRef
SXTBL = SXTbl *DREF *SxTbpg *(SXTBRGIITM *SXString)
DBQUERY = DbOrParamQry [1*SXString [DbOrParamQry *(SXString DbOrParamQry)]] *SXString
DOCROUTE = DocRoute 1*65535RecipName
BUNDLESHEET = BoundSheet8
METADATA = *MDTINFO *MDXSTR *(MDXTUPLESET / MDXProp / MDXKPI) *MDBLOCK
MDTINFO = MDTInfo *ContinueFrt12
MDXSTR = MDXStr *ContinueFrt12
MDXTUPLESET = (MDXTuple / MDXSet) *ContinueFrt12
MDBLOCK = MDB *ContinueFrt12
SUPBOOK = SupBook [*ExternName *(XCT *CRN)] [ExternSheet] *Continue
LBL = Lbl [NameCmt] [NameFnGrp12] [NamePublish]
RTD = RealTimeData *ContinueFrt
MSODRAWINGGROUP = MsoDrawingGroup *Continue
SHAREDSTRINGS = SST *Continue
THEME = Theme *ContinueFrt12
In the production the specification writes ExtSst; its record section
(2.4.107) is headed ExtSST. The SXADDLCACHE productions are on the
SXAddl page.
Worksheet substream (2.1.7.20.5)
WORKSHEET = BOF WORKSHEETCONTENT
WORKSHEETCONTENT = [Uncalced] Index GLOBALS PAGESETUP [HeaderFooter] [BACKGROUND] *BIGNAME
[PROTECTION] COLUMNS [SCENARIOS] SORTANDFILTER Dimensions [CELLTABLE] OBJECTS *HFPicture
*Note *PIVOTVIEW [DCON] 1*WINDOW *CUSTOMVIEW *2SORT [DxGCol] *MergeCells [LRng]
*QUERYTABLE [PHONETICINFO] CONDFMTS *HLINK [DVAL] [CodeName] *WebPub *CellWatch
[SheetExt] *FEAT *FEAT11 *RECORD12 EOF
SCENARIOS = ScenMan *(SCENARIO *Continue)
SORTANDFILTER = [Sort] [SORTDATA12] [FilterMode] [DropDownObjIds] [AUTOFILTER]
QUERYTABLE = Qsi DBQUERY QsiSXTag DBQUERYEXT [SXADDLQSI] [QSIR] [SORTDATA12]
SXADDLQSI = SXAddl_SXCQsi_SXDId SXADDLDBQUERY *UNKNOWNFRT SXAddl_SXCQsi_SXDEnd
QSIR = Qsir *Qsif
DBQUERYEXT = DBQueryExt [ExtString] *4[OleDbConn *ExtString] [TxtQry *ExtString]
CONDFMTS = *(CONDFMT / CONDFMT12) *(CFEx [CF12])
CONDFMT = CondFmt 1*3CF
CONDFMT12 = CondFmt12 1*CF12
HLINK = HLink [HLinkTooltip]
DVAL = DVal *65534Dv
PIVOTVIEW and its parts (PIVOTCORE, PIVOTFRT,
PIVOTVD, PIVOTEX and so on) and PIVOTADDL with the
SXAddl productions are on the
PivotTables and
SXAddl pages.
Macro sheet substream (2.1.7.20.4)
An international macro sheet if the Intl record (2.4.147) is present. The Table record (2.4.319) must not appear in it.
MACROSHEET = BOF MACROSHEETCONTENT
MACROSHEETCONTENT = [Uncalced] Index [Intl] GLOBALS PAGESETUP [HeaderFooter] [BACKGROUND]
*BIGNAME [PROTECTION] COLUMNS MACROSORTANDFILTER Dimensions [CELLTABLE] OBJECTS
*HFPicture *Note [DCON] 1*WINDOW *CUSTOMVIEW *2SORT [DxGCol] [PHONETICINFO] [CodeName]
*CellWatch [SheetExt] *FEAT *RECORD12 EOF
MACROSORTANDFILTER = [Sort] [SORTDATA12] [DropDownObjIds] [AUTOFILTER]
Dialog sheet substream (2.1.7.20.2)
DIALOGSHEET = BOF DIALOGSHEETCONTENT
DIALOGSHEETCONTENT = [Uncalced] Index GLOBALS PAGESETUP [HeaderFooter] *BIGNAME
[DIALOGPROTECTION] DefColWidth Dimensions OBJECTS *HFPicture *Note 1*DIALOGWINDOW
*DIALOGCUSTOMVIEW [CodeName] [SheetExt] *RECORD12 EOF
DIALOGPROTECTION = [Protect] [Password]
DIALOGWINDOW = Window2 [Pane] *Selection
DIALOGCUSTOMVIEW = UserSViewBegin *Selection [HorizontalPageBreaks] [VerticalPageBreaks] [Header]
[Footer] [HCenter] [VCenter] [LeftMargin] [RightMargin] [TopMargin] [BottomMargin] [Pls]
[Setup] [PrintSize] [HeaderFooter] UserSViewEnd
OBJECTS = *(MSODRAWING *(TEXTOBJECT / OBJ)) [MsoDrawingSelection]
MSODRAWING = MsoDrawing *Continue
OBJ = Obj *Continue
TEXTOBJECT = TxO *Continue
Common productions (2.1.7.20.6)
Fragments shared by several substreams. In a worksheet or macro sheet,
OBJ may be followed by embedded chart substreams; WINDOW
there includes the PLV record (0x088B, 2.4.200), described on the
worksheet page.
GLOBALS = CalcMode CalcCount CalcRefMode CalcIter CalcDelta CalcSaveRecalc PrintRowCol PrintGrid
GridSet Guts DefaultRowHeight WsBool [Sync] [LPr] [HorizontalPageBreaks]
[VerticalPageBreaks]
PAGESETUP = Header Footer HCenter VCenter [LeftMargin] [RightMargin] [TopMargin] [BottomMargin]
[Pls *Continue] Setup
BACKGROUND = BkHim *Continue
BIGNAME = BigName *ContinueBigName
PROTECTION = [Protect] [ScenarioProtect] [ObjProtect] [Password]
COLUMNS = DefColWidth *255ColInfo
AUTOFILTER = AutoFilterInfo *(AutoFilter / (AutoFilter12 *ContinueFrt12)) *SORTDATA12
CELLTABLE = 1*(1*Row *CELL 1*DBCell) *EntExU2
CELL = FORMULA / Blank / MulBlank / RK / MulRk / BoolErr / Number / LabelSst
FORMULA = [Uncalced] Formula [Array / Table / ShrFmla / SUB] [String *Continue]
PHONETICINFO = PhoneticInfo *Continue
OBJECTS = *(MSODRAWING *(TEXTOBJECT / OBJ)) [MsoDrawingSelection]
MSODRAWING = MsoDrawing *Continue
OBJ = Obj *Continue *CHART
CHART = CHARTSHEET *Continue
TEXTOBJECT = TxO *Continue
DCON = DCon *(DConName / DConBin / DConRef)
WINDOW = Window2 [PLV] [Scl] [Pane] *Selection
CUSTOMVIEW = UserSViewBegin *Selection [HorizontalPageBreaks] [VerticalPageBreaks] [Header]
[Footer] [HCenter] [VCenter] [LeftMargin] [RightMargin] [TopMargin] [BottomMargin] [Pls]
[Setup] [PrintSize] [HeaderFooter] [AUTOFILTER] UserSViewEnd
SORT = RRSort *Continue
SORTDATA12 = SortData *ContinueFrt12
PIVOTRULE = SxRule *PRFILTER
PRFILTER = SxFilt [SxItm *Continue]
FEAT = FeatHdr *(Feat *ContinueFrt)
FEAT11 = FeatHdr11 *((Feature11 / Feature12) *ContinueFrt11 *List12 [AutoFilter12 *ContinueFrt12]
*List12 [SORTDATA12])
RECORD12 = HeaderFooter
SXADDLDBQUERY = [SXAddl_SXCQuery_SXDXMLSource *Continue_SxaddlSxString]
[SXAddl_SXCQuery_SXDSrcDataFile *Continue_SxaddlSxString] [SXAddl_SXCQuery_SXDSrcConnFile
*Continue_SxaddlSxString] [SXAddl_SXCQuery_SXDReconnCond] SXAddl_SXCQuery_SXDEnd
UNKNOWNFRT = SXAddl
Line breaks inside a production are the page’s; the specification wraps them at its
page width. Where the Globals productions and the common productions use the same name
(PROTECTION: Globals has WinProtect Protect Password Prot4Rev Prot4RevPass,
the common one only the sheet protection records), the substream’s own production
applies inside it.
Checks. scripts/xls/grammarcheck.mjs
reads the productions above from the specification text, turns each into a regular
expression over record names and matches every Globals and Worksheet substream of the
BIFF8 files in the sample folder (Continue records and nested chart substreams left out;
the 20 substreams of BIFF5 files and of the three encrypted files are skipped). 216
substreams match (58 of 69 Globals, 158 of 177 worksheets). The 30 that do not
have four causes, each a writer departing from the grammar and not a transcription
error as far as they were looked into: (1) files written by LibreOffice (12 substreams, 6 files) omit
WinProtect, Protect and Password from the Globals substream, and
omit Index and CalcMode from every worksheet and put Guts and the print records in a
different order; (2) three files made with Apache POI’s writer differ: in
poi-3dFormulas.xls Palette follows UsesELFs in Globals, in
poi-SharedFormulaTest.xls the worksheet carries PLV (0x088B) after FeatHdr and
HeaderFooter at the very end, where the grammar puts it in WINDOW straight after Window2
(removing it makes the sheet match), and its Globals writes XFCRC, XFExt (41),
StyleExt (47), TableStyles, MTRSettings, ForceFullCalculation, Theme, CompressPictures and
Compat12 after BookExt, which follows ExtSST, where the grammar puts XFCRC and XFExt in
XFS, StyleExt in STYLES, TableStyles in FORMATTING, and MTRSettings and
ForceFullCalculation before Country; and poi-WithExtendedStyles.xls has
one Format record where the grammar needs at least eight, and each of its three
worksheets omits Index and CalcMode and writes PrintRowCol, PrintGrid and GridSet after Guts, DefaultRowHeight and
WsBool instead of before Guts (this reading comes from the record order listed by
recorder.mjs; the check reports no single record whose removal fixes them); (3) the Excel-written
poi-1900DateWindowing.xls, poi-1904DateWindowing.xls,
poi-FormatChoiceTests.xls and poi-atp.xls hold the unknown
records 0x08C8 (a worksheet, after Window2) and 0x08D6 (Globals, before SST), which
the grammar does not name (see the overview);
removing that one record makes the substream match. No file in the sample folder has a
macro sheet substream (BOF type 0x40), and the folder’s dialog sheets, if any, are
not told apart from worksheets, so those two productions are transcribed but not
exercised by a real file. The chart sheet and the PivotTable productions are checked
on their own pages.
BOF (0x0809)
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 2 | vers | BIFF version: 0x0600. |
2 | 2 | dt | Substream type: 0x0005 globals, 0x0010 worksheet or dialog sheet, 0x0020 chart, 0x0040 macro sheet. |
4 | 2 | rupBuild | Build number of the application. |
6 | 2 | rupYear | 0x07CC (1996, written by Excel 97) or 0x07CD (1997). |
8 | 4 | flags | Bit 0 fWin (1), 1 fRisc, 2 fBeta, 3 fWinAny, 4 fMacAny, 5 fBetaAny, 8 fRiscAny, 9 fOOM (ran out of memory), 10 fGlJmp (ran out of memory while drawing), 13 fFontLimit (hit 255 fonts, Excel 97), bits 14–17 verXLHigh, the newest Excel that ever saved the file. |
12 | 1 | verLowestBiff | 6. |
13 | 1 | verLastXLSaved | Low 4 bits: the Excel that saved it last. |
14 | 2 | reserved | 0. |
Application versions in verXLHigh and verLastXLSaved:
0 Excel 97, 1 Excel 2000, 2 Excel 2002, 3 Excel 2003, 4 Excel 2007, 6 Excel 2010,
7 Excel 2013 (section 2.4.21 and its notes).
BoundSheet8 (0x0085)
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 4 | lbPlyPos | Stream offset of the sheet’s BOF record. |
4 | 1 | hsState (bits 0–1) | 0 visible, 1 hidden, 2 very hidden (cannot be unhidden from the interface). |
5 | 1 | dt | 0 worksheet or dialog sheet, 1 macro sheet, 2 chart sheet, 6 VBA module. |
6 | varies | stName | Sheet name as a ShortXLUnicodeString, 1 to 31 characters, unique ignoring case. |
Finding cells quickly: Index and DBCell
A worksheet’s rows are stored in blocks of up to 32: the Row records of
the block, then their cell records, then a DBCell. The
Index record near the start of the sheet points to every DBCell.
| Record | Fields |
|---|---|
Index (0x020B) | 4 reserved bytes; rwMic (4), the first row with data; rwMac (4), one more than the last; ibXF (4), stream offset of the DefColWidth record; then one 4-byte stream offset per DBCell. |
DBCell (0x00D7) | dbRtrw (4): from this record back to the block’s first Row record; then up to 32 two-byte offsets: the first from the end of the first Row record to that row’s first cell, each later one from the previous row’s first cell. |
Readers may ignore both and simply read records in order.
Encryption: FilePass (0x002F)
If the globals substream contains FilePass, the workbook is
encrypted (section 2.4.117). Its first two bytes, wEncryptionType, are
0 for XOR obfuscation or 1 for RC4. For RC4 the next two bytes choose the header: 1
the original RC4 header ([MS-OFFCRYPTO] 2.3.6.1); 2, 3 or 4 the RC4 CryptoAPI header
([MS-OFFCRYPTO] 2.3.5.1). Record types and sizes stay readable, and so do the
records BOF, FilePass, UsrExcl,
FileLock, InterfaceHdr, RRDInfo and
RRDHead and the lbPlyPos field of
BoundSheet8; all other record data is encrypted (section 2.2.10). RC4
works in 1,024-byte blocks counted from the start of the stream, with the skipped
bytes still fed through the cipher as zeros so the key stream stays in step. With
RC4 CryptoAPI some other streams move into the encryption stream.
What the programs do: the specification exempts seven records and the
lbPlyPos field ([MS-XLS] 2.2.10). xlrd stops at any FilePass with “Workbook is encrypted”
(xlrd/book.py lines 922–943). SheetJS decrypts XOR and RC4 files when given
a password, and leaves the whole BoundSheet8 record undecrypted, not only
lbPlyPos (xlsx.flow.js lines 19189–19196).
Divergence from the specification
- Stream name. [MS-XLS] names the stream
Workbook. xlrd looks forWorkbookand thenBook(xlrd/book.pylines 639–645) and SheetJS does the same (xlsx.flow.jsline 19817); the viewer reads both, as the BIFF5 stream is calledBook. - Encrypted BoundSheet8. The specification exempts only
lbPlyPos; SheetJS leaves the entire record plain (see above). - Zero records. A record with type 0 and size 0 is not defined in
[MS-XLS]. LibreOffice skips up to five of them, noting that “Crystal Report” writes
them between records (
sc/source/filter/excel/xistream.cxxlines 460–474); the viewer lists them as records of type 0 and carries on.
Key programs
- xlrd –
xlrd/book.py(stream lookup, FilePass). - SheetJS –
xlsx.flow.js(parse_xlscfb,parse_FilePass, the record loop). - LibreOffice Calc –
xistream.cxx(record reader and decrypter).