Element names below are from ECMA-376 Part 1, chapter 18 (SpreadsheetML). A worksheet has up to 1,048,576 rows and 16,384 columns (A to XFD).
A worksheet part
The root worksheet holds, in order: sheetPr,
dimension (the used range, such as A1:D20),
sheetViews, sheetFormatPr (default row height and column
width), cols (col elements with min,
max, width, style, hidden,
outlineLevel), sheetData, then protection, auto-filter,
mergeCells, conditionalFormatting,
dataValidations, hyperlinks, page setup, headers and
footers, drawing, tableParts and extLst.
<sheetData>
<row r="1" spans="1:3">
<c r="A1" t="s"><v>0</v></c>
<c r="B1"><v>42.5</v></c>
<c r="C1" s="1"><f>B1*2</f><v>85</v></c>
</row>
</sheetData>
A row has r (1-based row number), and optionally
spans (a hint of the columns used), s with
customFormat (row style), ht with
customHeight (height in points), hidden,
outlineLevel, collapsed, thickTop,
thickBot and ph. Rows and cells appear in order; missing
ones are empty.
Cells
| Attribute or child | Meaning |
|---|---|
r | The cell’s A1-style reference. May be omitted, in which case the cell follows the previous one. |
s | Index into the cellXfs list; default 0. |
t | Type of the value, default n (below). |
cm, vm | Cell metadata and value metadata indexes (the metadata part). |
ph | Show phonetic guides. |
f | The formula, if any. |
v | The value (for a formula, the last calculated result). |
is | Inline rich text, for t="inlineStr". |
t | Type | The v element holds |
|---|---|---|
n | Number | A number in decimal text, such as 42.5 or 1E-3. |
s | Shared string | A 0-based index into the shared strings. |
str | Formula string | Text result of a formula. |
inlineStr | Inline string | No v: the text is in is, as in a shared string item. |
b | Boolean | 0 or 1. |
e | Error | One of #NULL!, #DIV/0!, #VALUE!, #REF!, #NAME?, #NUM!, #N/A. |
d | Date | An ISO 8601 date and time as text, such as 2012-03-01T14:30:00 (below). |
The d type is not in the first edition of ECMA-376 (its
ST_CellType has only the six types above). Microsoft’s Open XML SDK lists it as
CellValues.Date, written "d", “only available in Office
2010 and later”. It is a feature of Strict SpreadsheetML, which can store a date as
text instead of a serial number: only local dates and times from 0001-01-01 00:00 to
9999-12-31 23:59:59.999, with no time zone or UTC marker, written as
YYYY-MM-DD, hh:mm:ss or
YYYY-MM-DDThh:mm:ss (a write-up of Strict dates on Eric
White’s blog, which shows the
same date as <v>40957</v> in a transitional file and as
t="d" with <v>2012-03-01T14:30:00</v> in a
Strict one). A reader should accept both forms.
Dates and times are ordinary numbers shown with a date format: the whole part is a
day count and the fraction the time of day. In the default 1900 system day 1 is
1 January 1900, and Excel counts a non-existent 29 February 1900 (day 60) for
compatibility with Lotus 1-2-3; with date1904 set in
workbookPr, day 0 is 1 January 1904.
Formulas
The formula is stored as text without the leading =, using A1
references and English function names; functions newer than Excel 2007 carry a
prefix such as _xlfn.. Attributes of f:
| Attribute | Meaning |
|---|---|
t | normal (default), array (an array formula over ref), dataTable (a what-if data table, with dt2D, dtr, del1, del2, r1, r2), shared (a formula shared by several cells). |
ref | Range an array, data table or shared formula covers. |
si | Shared formula group index. The first cell of the group has t="shared", ref, si and the text; the other cells have only t="shared" and si, and adjust its relative references. |
ca | Calculate the cell every time (volatile). |
aca, bx | Always calculate an array formula; the formula assigns a value to a name. |
The styles part
xl/styles.xml (styleSheet) holds, in order:
numFmts (custom number formats, each numFmtId and
formatCode, ids 164 and up), fonts, fills
(the first two are reserved: none and gray125), borders,
cellStyleXfs (formats of named styles), cellXfs (the cell
formats a cell’s s points to: numFmtId,
fontId, fillId, borderId, xfId,
apply… flags, and child alignment and
protection), cellStyles (named styles, with
builtinId), dxfs (differential formats for conditional
formatting and tables), tableStyles, colors (custom
indexed palette and recent colours) and extLst. Every element and
attribute is on the styles part
page.
Built-in number formats
Number format ids below 164 are built in and need no numFmt
element (ECMA-376 Part 1, 18.8.30; Excel’s binary formats share them):
| Id | Format | Id | Format |
|---|---|---|---|
| 0 | General | 20 | h:mm |
| 1 | 0 | 21 | h:mm:ss |
| 2 | 0.00 | 22 | m/d/yy h:mm |
| 3 | #,##0 | 37 | #,##0 ;(#,##0) |
| 4 | #,##0.00 | 38 | #,##0 ;[Red](#,##0) |
| 9 | 0% | 39 | #,##0.00;(#,##0.00) |
| 10 | 0.00% | 40 | #,##0.00;[Red](#,##0.00) |
| 11 | 0.00E+00 | 45 | mm:ss |
| 12 | # ?/? | 46 | [h]:mm:ss |
| 13 | # ??/?? | 47 | mmss.0 |
| 14 | mm-dd-yy | 48 | ##0.0E+0 |
| 15 | d-mmm-yy | 49 | @ (text) |
| 16 | d-mmm | ||
| 17 | mmm-yy | ||
| 18 | h:mm AM/PM | ||
| 19 | h:mm:ss AM/PM |
Some ids are shown differently depending on the application’s language, and further ids exist only for East Asian and Thai versions:
| Id | zh-TW | zh-CN | ja-JP | ko-KR |
|---|---|---|---|---|
| 27 | [$-404]e/m/d | yyyy"年"m"月" | [$-411]ge.m.d | yyyy"年" mm"月" dd"日" |
| 28 | [$-404]e"年"m"月"d"日" | m"月"d"日" | [$-411]ggge"年"m"月"d"日" | mm-dd |
| 29 | [$-404]e"年"m"月"d"日" | m"月"d"日" | [$-411]ggge"年"m"月"d"日" | mm-dd |
| 30 | m/d/yy | m-d-yy | m/d/yy | mm-dd-yy |
| 31 | yyyy"年"m"月"d"日" | yyyy"年"m"月"d"日" | yyyy"年"m"月"d"日" | yyyy"년" mm"월" dd"일" |
| 32 | hh"時"mm"分" | h"时"mm"分" | h"時"mm"分" | h"시" mm"분" |
| 33 | hh"時"mm"分"ss"秒" | h"时"mm"分"ss"秒" | h"時"mm"分"ss"秒" | h"시" mm"분" ss"초" |
| 34 | 上午/下午hh"時"mm"分" | 上午/下午h"时"mm"分" | yyyy"年"m"月" | yyyy-mm-dd |
| 35 | 上午/下午hh"時"mm"分"ss"秒" | 上午/下午h"时"mm"分"ss"秒" | m"月"d"日" | yyyy-mm-dd |
| 36 | [$-404]e/m/d | yyyy"年"m"月" | [$-411]ge.m.d | yyyy"年" mm"月" dd"日" |
| 50 | [$-404]e/m/d | yyyy"年"m"月" | [$-411]ge.m.d | yyyy"年" mm"月" dd"日" |
| 51 | [$-404]e"年"m"月"d"日" | m"月"d"日" | [$-411]ggge"年"m"月"d"日" | mm-dd |
| 52 | 上午/下午hh"時"mm"分" | yyyy"年"m"月" | yyyy"年"m"月" | yyyy-mm-dd |
| 53 | 上午/下午hh"時"mm"分"ss"秒" | m"月"d"日" | m"月"d"日" | yyyy-mm-dd |
| 54 | [$-404]e"年"m"月"d"日" | m"月"d"日" | [$-411]ggge"年"m"月"d"日" | mm-dd |
| 55 | 上午/下午hh"時"mm"分" | 上午/下午h"时"mm"分" | yyyy"年"m"月" | yyyy-mm-dd |
| 56 | 上午/下午hh"時"mm"分"ss"秒" | 上午/下午h"时"mm"分"ss"秒" | m"月"d"日" | yyyy-mm-dd |
| 57 | [$-404]e/m/d | yyyy"年"m"月" | [$-411]ge.m.d | yyyy"年" mm"月" dd"日" |
| 58 | [$-404]e"年"m"月"d"日" | m"月"d"日" | [$-411]ggge"年"m"月"d"日" | mm-dd |
Thai (th-TH): 59 t0, 60 t0.00, 61 t#,##0,
62 t#,##0.00, 67 t0%, 68 t0.00%, 69
t# ?/?, 70 t# ??/??, 71 ว/ด/ปปปป, 72
ว-ดดด-ปป, 73 ว-ดดด, 74 ดดด-ปป, 75
ช:นน, 76 ช:นน:ทท, 77 ว/ด/ปปปป ช:นน, 78
นน:ทท, 79 [ช]:นน:ทท, 80 นน:ทท.0, 81
d/m/bb. The ids 5–8, 23–26 and 41–44 have no fixed text in the standard;
Microsoft’s [MS-XLS] treats them as locale-dependent formats that a file defines with
its own format string, so a reader should take them from numFmts.