ODS is the spreadsheet type of the OpenDocument Format (ODF), an OASIS standard also published as ISO/IEC 26300. This page follows ODF 1.3: Part 2 defines the package and Part 3 the XML schema; section numbers refer to Part 3.
The package
An ODS file is a ZIP package laid out as for every OpenDocument type (see the
ODT package page for the
details): a first, uncompressed entry mimetype containing
application/vnd.oasis.opendocument.spreadsheet (or
…spreadsheet-template for .ots),
META-INF/manifest.xml listing every file and any encryption,
content.xml with the sheets, styles.xml,
meta.xml (title, author, dates, statistics) and
settings.xml (view settings such as the active sheet and zoom), and
often a Thumbnails/thumbnail.png. A spreadsheet may also be a single
XML file, Flat ODS (.fods), with all of these inside one
office:document element.
office:spreadsheet
In content.xml, office:document-content holds
office:automatic-styles and office:body, whose child
office:spreadsheet (3.7) may carry table:structure-protected
and a protection key, and holds the workbook-level elements
(table:calculation-settings, table:content-validations,
table:label-ranges, variable and field declarations), one
table:table per sheet, and then table:named-expressions
(named ranges), table:database-ranges,
table:data-pilot-tables (pivot tables), table:consolidation,
table:dde-links and table:tracked-changes.
table:table (9.1.2)
Attributes: table:name (the sheet name), table:style-name
(its table style, which says among other things whether the sheet is shown),
table:protected with table:protection-key and
table:protection-key-digest-algorithm, table:print,
table:print-ranges, table:is-sub-table,
table:template-name, the six table:use-…-styles banding
flags and xml:id. Children, in order: table:title,
table:desc, table:table-source (linked data),
table:scenario, office:forms,
table:shapes (drawings anchored to the sheet), the columns, the rows,
and table:named-expressions local to the sheet.
Columns are table:table-column elements (9.1.6), optionally grouped
in table:table-column-group, table:table-header-columns
(repeated on each printed page) or table:table-columns. Rows are
table:table-row elements (9.1.3), grouped the same way with
table:table-row-group, table:table-header-rows and
table:table-rows.
Rows and columns
| Attribute | On | Meaning |
|---|---|---|
table:number-columns-repeated | column, cell | This element stands for that many identical adjacent columns or cells (default 1). |
table:number-rows-repeated | row | This row stands for that many identical adjacent rows (default 1). Spreadsheets use it to describe the empty rows down to the last row of the sheet in a single element. |
table:style-name | column, row, cell | Automatic style giving width, height and cell formatting (see styles). |
table:default-cell-style-name | column, row | Style for cells in that column or row without their own. |
table:visibility | column, row | visible (default), collapse (hidden), filter (hidden by a filter) (19.754). |
Cells (9.1.4, 9.1.5)
A row contains table:table-cell elements, and
table:covered-table-cell elements for each cell hidden under a merged
cell. Both may hold text (text:p paragraphs, which carry the displayed
text), annotations (office:annotation, comments), drawings and even
nested tables.
| Attribute | Meaning |
|---|---|
office:value-type | Type of the cell’s value (below). |
office:value, office:currency, office:date-value, office:time-value, office:boolean-value, office:string-value | The value, by type. |
table:formula | Formula, beginning with a namespace prefix and a colon, normally of:= for OpenFormula (19.646). |
table:number-columns-spanned, table:number-rows-spanned | Size of a merged cell (default 1); the cells it covers follow as covered cells. |
table:number-matrix-columns-spanned, table:number-matrix-rows-spanned | Size of the result of an array (matrix) formula. |
table:number-columns-repeated | Number of identical adjacent cells. |
table:style-name | Cell style. |
table:content-validation-name | Data validation rule (9.4.5). |
table:protect, table:protected | Cell protection. |
xhtml:about, xhtml:content, xhtml:datatype, xhtml:property, xml:id | RDFa metadata and an identifier. |
Value types (19.389)
office:value-type | Value attribute | Encoding |
|---|---|---|
float | office:value | Number, such as 12.345. |
percentage | office:value | Number, such as 0.5 for 50%. |
currency | office:value and office:currency | Number and currency code, such as 100 and USD. |
date | office:date-value | XML Schema date or dateTime, such as 2003-04-17. |
time | office:time-value | XML Schema duration, such as PT03H30M00S. |
boolean | office:boolean-value | true or false. |
string | office:string-value, or the cell’s text if absent | Text. |
void | none | No value. |
Unlike in XLSX, dates are stored as dates, not as day counts, and the displayed text is stored as well as the value.
Cell addresses (9.2.1)
A cell address is the sheet name, a full stop and the column letters and row
number: Sheet1.A1, with column A being 1 and AA 27. Ranges join two
addresses with a colon (Sheet1.A1:Sheet1.B10). In OpenFormula, a
reference is written in square brackets, such as of:=SUM([.A1:.A10]),
where a leading dot means the formula’s own sheet and $ marks absolute
parts.
Data validation
Validation rules are declared once, in table:content-validations at the
start of office:spreadsheet, and a cell uses one by naming it in
table:content-validation-name. Each rule is a
table:content-validation element.
| Attribute | Meaning |
|---|---|
table:name | The name cells refer to. |
table:condition | What a value must satisfy, as an expression such as of:cell-content-is-between(1,10), of:cell-content-is-whole-number(), of:cell-content-text-length()>3 or of:is-true-formula(…); conditions can be joined with and. |
table:base-cell-address | The cell that relative references in the condition are relative to. |
table:allow-empty-cell | Whether an empty cell passes (default true). |
table:display-list | For a list condition, whether the choices are offered in a drop-down and in what order: none, unsorted or sort-ascending. |
Children: table:help-message (shown when the cell is selected, with
table:title, table:display and its text in
text:p paragraphs), table:error-message (shown when the value is
refused: table:title, table:display and
table:message-type, one of stop, warning or
information) and table:error-macro (table:execute:
whether a macro runs on an invalid entry). The message texts are part of the
document; a viewer should show them with the rule.
Database ranges, filters, sorting and subtotals
table:database-ranges holds one table:database-range for each
named area treated as a table of records.
| Attribute | Meaning |
|---|---|
table:name, table:target-range-address | The name, and the cells it covers. |
table:contains-header, calcext:contains-footer | Whether the first row holds column names (default true), and whether the last row is a footer (LibreOffice). |
table:orientation | column (records in rows, the default) or row. |
table:display-filter-buttons | Whether the header cells show filter buttons (an AutoFilter). |
table:is-selection | The range is an unnamed selection used by a sort or filter. |
table:on-update-keep-styles, table:on-update-keep-size | What a refresh from the source keeps. |
table:has-persistent-data, table:refresh-delay | Whether the imported data is stored in the file, and the interval between refreshes. |
A range imported from a database holds one of table:database-source-table,
table:database-source-query or table:database-source-sql,
carrying table:database-name and table:database-table-name,
table:query-name or table:sql-statement (with
table:parse-sql-statement).
Filter. table:filter has
table:target-range-address (where the result goes),
table:condition-source (self or cell-range, with
table:condition-source-range-address) and
table:display-duplicates. Its children are one expression of
table:filter-and, table:filter-or and
table:filter-condition elements. A condition names a column with
table:field-number (counted from 0 within the range), an operator in
table:operator (=, !=, <,
>, <=, >=, match,
!match, top values, top percent,
bottom values, bottom percent and others), a
table:value, table:data-type (text or
number) and table:case-sensitive. A condition can instead
hold table:filter-set-item elements, each with one
table:value, the values ticked in an AutoFilter list.
Sort. table:sort holds one table:sort-by per
key, each with table:field-number, table:data-type
(text, number or automatic) and
table:order (ascending or descending). The sort
itself may say table:case-sensitive, table:algorithm,
table:language, table:country, table:script,
table:rfc-language-tag, table:embedded-number-behavior and
table:bind-styles-to-content.
Subtotals. table:subtotal-rules holds
table:sort-groups (table:data-type, table:order)
and one table:subtotal-rule per grouping column
(table:group-by-field-number), which in turn holds
table:subtotal-field elements giving a column
(table:field-number) and the function (table:function) to
total it with. table:page-breaks-on-group-change puts each group on its
own page.
Pivot tables (data pilot)
A pivot table summarises a block of records by cross-tabulating some columns. Each is a
table:data-pilot-table inside table:data-pilot-tables. The
file stores the definition; the result cells are ordinary cells in the sheet.
| Attribute | Meaning |
|---|---|
table:name, table:application-data | The name, and text the producing program keeps for itself. |
table:target-range-address | Where the result is written. |
table:grand-total | Which grand totals are shown: none, row, column or both. |
table:ignore-empty-rows, table:identify-categories | Skip empty source rows; fill a blank category cell from the one above. |
table:buttons | The cell addresses where field buttons are drawn. |
table:show-filter-button, table:drill-down-on-double-click, loext:show-drill-down-buttons | Interface options. |
The data comes from one source element: table:source-cell-range
(table:cell-range-address, optionally with a table:filter that
pre-selects rows), table:source-service (table:name,
table:source-name, table:object-name,
table:user-name and table:password, for a service such as an
external data provider), or table:database-source-table,
table:database-source-query or table:database-source-sql as
for database ranges.
Then comes one table:data-pilot-field for each source column used, which
says where it goes and how it is summarised:
| Attribute or child | Meaning |
|---|---|
table:source-field-name | The column heading in the source. |
table:orientation | row, column, data (the values to summarise), page (a filter above the table) or hidden. |
table:function | The summary for a data field: sum, count, average, max, min and so on (a custom function can be given with calcext:formula). |
table:is-data-layout-field | This is the generated "Data" field that lays several data fields out as rows or columns. |
table:selected-page, table:used-hierarchy, tableooo:display-name | The page field's chosen item, the hierarchy level in use, and the caption shown instead of the source name. |
table:data-pilot-level | One level of the field, holding table:data-pilot-subtotals (each table:data-pilot-subtotal names a table:function), table:data-pilot-members (each table:data-pilot-member with table:name, table:display and table:show-details), table:data-pilot-sort-info (table:sort-mode none, manual, name or data, with table:order and table:data-field), table:data-pilot-display-info (show only the top or bottom items: table:enabled, table:member-count, table:display-member-mode, table:data-field) and table:data-pilot-layout-info (table:layout-mode and table:add-empty-lines). table:show-empty keeps categories with no data. |
table:data-pilot-field-reference | Shows a data field relative to another value instead of as itself: table:type (none, member-difference, member-percentage, member-percentage-difference, running-total, row-percentage, column-percentage, total-percentage, index) with table:field-name, table:member-name and table:member-type (named, previous or next). |
table:data-pilot-groups | Groups the items of a field. Numbers and dates are grouped by range: table:start, table:end, table:step, table:date-start, table:date-end and table:grouped-by (seconds, minutes, hours, days, months, quarters or years); text items by hand, as table:data-pilot-group elements each listing table:data-pilot-group-member names. |
Change tracking
With table:track-changes true, table:tracked-changes (at the
start of office:spreadsheet) lists the edits that are still open. Every
entry carries table:id (cell content refers to it), an
office:change-info with the author and date,
table:acceptance-state (pending, accepted or
rejected), table:rejecting-change-id when a later change
undid it, and table:dependencies naming the changes it depends on
(table:dependency, with table:id).
| Element | Records |
|---|---|
table:insertion | Rows, columns or a sheet added: table:type (row, column or table), table:position, table:table and table:count. |
table:deletion | Rows, columns or a sheet removed: the same attributes plus table:multi-deletion-spanned. table:cut-offs (table:insertion-cut-off, table:movement-cut-off, whose table:position is the index of the row or column cut and, for a movement, table:start-position and table:end-position (integers) give the first and last row or column of the span cut) say which earlier changes it cut short, and table:deletions lists the cell contents (table:cell-content-deletion) and changes (table:change-deletion) lost with it. |
table:movement | Cells moved: table:source-range-address and table:target-range-address, each with the integer attributes table:start-column, table:start-row, table:start-table, table:end-column, table:end-row and table:end-table (first and last column, row and sheet of the range, counted from 0), and the table:deletions the move overwrote. |
table:cell-content-change | A cell edited: table:cell-address (integer attributes table:column, table:row and table:table, the position of the cell) and, in table:previous, the old content as a table:change-track-table-cell (the cell's value attributes, table:formula, table:matrix-covered (boolean: the cell lies inside a matrix formula's range), and its text). |
Conditional formatting
ODF 1.3 stores a conditional format in the cell style: style:map elements,
each with style:condition (cell-content()>3,
is-true-formula(…)), style:apply-style-name and
style:base-cell-address. LibreOffice also writes its own richer form, in the
calcext namespace, at the end of each sheet:
calcext:conditional-formats holds one calcext:conditional-format
per set of cells (calcext:target-range-address), with one or more of:
| Element | Meaning |
|---|---|
calcext:condition | A rule: calcext:value (for example cell-content()>3), the style to apply (calcext:apply-style-name) and calcext:base-cell-address. |
calcext:color-scale | Colours blended between values: calcext:color-scale-entry elements with calcext:type (minimum, maximum, percentile, percent, formula, value), calcext:value and calcext:color. |
calcext:data-bar | A bar in the cell: calcext:positive-color, calcext:negative-color, calcext:axis-color, calcext:axis-position, calcext:max-length, and calcext:formatting-entry elements giving the shortest and longest value (calcext:type, calcext:value). |
Sparklines (small charts inside a cell) are likewise stored by LibreOffice:
calcext:sparkline-groups holds calcext:sparkline-group
elements that carry the shared look (type, colours, axis settings) and
calcext:sparklines lists each calcext:sparkline with its
calcext:cell-address and calcext:data-range.
Named ranges, labels, consolidation and calculation settings
| Element | Attributes and meaning |
|---|---|
table:named-range | table:name, table:cell-range-address, table:base-cell-address and table:range-usable-as (none, or a space-separated list of print-range, filter, repeat-row, repeat-column). |
table:named-expression | A name for a formula: table:name, table:expression, table:base-cell-address; loext:hidden marks a name the program keeps for itself. |
table:label-range | Cells whose text names the data beside them, so a formula may say "Sales": table:label-cell-range-address, table:data-cell-range-address and table:orientation. |
table:consolidation | Combines several ranges into one: table:function, table:source-cell-range-addresses, table:target-cell-address, table:use-labels (none, row, column or both) and table:link-to-source-data. |
table:calculation-settings | table:case-sensitive, table:precision-as-shown, table:search-criteria-must-apply-to-whole-cell, table:automatic-find-labels, table:use-regular-expressions, table:use-wildcards and table:null-year; its children table:null-date (table:date-value, table:value-type: the day numbered 0, which date serial numbers count from) and table:iteration (table:status, table:steps, table:maximum-difference: circular references). |
Example
<table:table table:name="Sheet1" table:style-name="ta1">
<table:table-column table:style-name="co1" table:number-columns-repeated="2"/>
<table:table-row table:style-name="ro1">
<table:table-cell office:value-type="string"><text:p>Total</text:p></table:table-cell>
<table:table-cell table:formula="of:=SUM([.B2:.B9])"
office:value-type="float" office:value="42"><text:p>42</text:p></table:table-cell>
</table:table-row>
<table:table-row table:number-rows-repeated="1048575">
<table:table-cell table:number-columns-repeated="2"/>
</table:table-row>
</table:table>