2.2.1 Cell Table
Text, formulas, and numerical data within worksheets are primarily stored in the cells that make up worksheets (section 2.1.7.62) and macro sheets (section 2.1.7.32). Cells are the fundamental building blocks that contain data, formulas (section 2.2.2), and formatting to form the worksheets. The data structure associated with the grid of cells is called the cell table.
The cell table is stored in the sequence of records that conform to the CELLTABLE rule in the Common Productions (section 2.1.8) part ABNF. The cells are contained between BrtBeginSheetData (section 2.4.200) and BrtEndSheetData (section 2.4.550) records. They are stored in a row-major order, with a BrtRowHdr (section 2.4.761) record saved for every non-empty row, where a non-empty row is a row that contains data, formatting, metadata, or phonetic information.
Every row is divided into 16 column (1) blocks, and each column (1) block spans 1024 columns (1). Each BrtRowHdr (section 2.4.761) record contains an array of BrtColSpan (section 2.5.9) structures that specifies the column (1) blocks in that row that have non-empty cells, where a non-empty cell is a cell that contains data, individual cell formatting, metadata, or phonetic information. Formatting information for a cell can be derived from individual cell formatting, row formatting, column (1) formatting, or the default cell format as specified by the Normal Style (section 2.2.6.1.2.2). The order of precedence for formatting is individual cell formatting with the highest precedence, followed by row formatting, and then column (1) formatting, and lastly the default cell format.
Cells are specified by BrtCellBlank (section 2.4.316), BrtCellRk (section 2.4.324), BrtCellError (section 2.4.318), BrtCellBool (section 2.4.317), BrtCellReal (section 2.4.323), BrtCellSt (section 2.4.327), BrtCellIsst (section 2.4.321), BrtFmlaString (section 2.4.680), BrtFmlaNum (section 2.4.679), BrtFmlaBool (section 2.4.677), BrtFmlaError (section 2.4.678), or BrtCellRString (section 2.4.325) records. Each of these records contains a Cell (section 2.5.10) structure that specifies which column (1) the cell belongs to.
The sequence of records that conform to the CELLTABLE rule (defined in section 2.1.8) begin with the BrtBeginSheetData (section 2.4.200) record, followed by the first BrtRowHdr (section 2.4.761) representing the first non-empty row. The BrtRowHdr is followed by records representing every non-empty cell in that row in column (1)-major order, including any of the records in the CELL rule (defined in section 2.1.8). This series of records is repeated for every non-empty row and non-empty cell, and ends with the BrtEndSheetData (section 2.4.550) record.
A cell in the cell table is referred to by its row and column (1) indexes, which are zero-based. The maximum row index is 1048575; the maximum column (1) index is 16383. The bounding box of the actual non-empty cells is stored in the BrtWsDim (section 2.4.858) record. Information pertaining to each column (1) is specified in the COLINFOS collection (section 2.1.8).