ODF has one table model for every kind of document: a word processing table and a
spreadsheet sheet are both table:table. A table is a grid stored row by
row; columns are described once, at the top, and each row holds its cells in order.
This page covers sections 9.1 to 9.3 of OpenDocument 1.3 part 3 and the attributes
those elements take (chapter 19). The spreadsheet-only parts of chapter 9 (validation,
named ranges, database ranges, filters, data pilot tables, consolidation, change
tracking in sheets) belong to ODS. How a
table looks (widths, borders, backgrounds) is set by styles, described on the
table formatting page.
Table elements
A table:table can stand in the text body, a section, a header or
footer, a frame or text box, a note, an index body, a deleted-text record, or inside
another table’s cell. Its children come in this order: optional title and
description, optional link source, scenario, forms, shapes and named expressions,
then the columns, then the rows.
| Element | Meaning | Attributes | Children |
|---|---|---|---|
table:table | A table. | table:name, table:style-name, table:template-name, the six table:use-…-styles switches, table:is-sub-table, table:print, table:print-ranges, table:protected, table:protection-key, table:protection-key-digest-algorithm, xml:id | table:title, table:desc, table:table-source, table:scenario, office:forms, table:shapes, table:named-expressions, office:dde-source, column elements, row elements, text:soft-page-break |
table:title | The table’s title, as text. Not used when the table is inside a draw:frame; the frame’s svg:title is used instead. | – | text |
table:desc | A description for accessibility, as text. Not used inside a draw:frame (the frame’s svg:desc is). | – | text |
table:table-column | One or more adjacent columns with the same properties. | table:style-name, table:default-cell-style-name, table:number-columns-repeated, table:visibility, xml:id | none |
table:table-columns | A run of columns; means the same as if the start and end tags were not there. | – | table:table-column |
table:table-header-columns | Header columns: repeated on every page when the table is too wide for one. | – | table:table-column |
table:table-column-group | A group of adjacent columns, which can be shown or hidden as one; may nest. | table:display | columns, header columns, column groups |
table:table-row | A row, holding its cells. | table:style-name, table:default-cell-style-name, table:number-rows-repeated, table:visibility, xml:id | table:table-cell, table:covered-table-cell |
table:table-rows | A run of rows; means the same as if the tags were not there. | – | table:table-row, text:soft-page-break |
table:table-header-rows | Header rows: repeated at the top of every page the table runs onto. A reader that does not support them treats them as ordinary rows. | – | table:table-row, text:soft-page-break |
table:table-row-group | A group of adjacent rows, which can be shown or hidden as one; may nest. | table:display | header rows, rows, row groups, text:soft-page-break |
table:table-cell | A cell. It may hold paragraphs, headings, lists, sections, indexes, nested tables, shapes and frames, annotations and tracked-change marks, or nothing. | see Cells | block content, shapes, table:cell-range-source, table:detective |
table:covered-table-cell | A cell position hidden by a cell that spans over it. There is one for each covered position, in document order. Spreadsheets may keep content in covered cells. | as table:table-cell, without the span attributes | as table:table-cell |
table:shapes | Shapes anchored to the table. | – | drawing shapes and frames |
A table may have only one table:table-header-rows, unless it has row
groups: then the table and each group may have one, as long as all the header rows
are next to each other. The same rule applies to header columns and column groups.
A column group may contain header columns, but not the other way round.
Repeats, spans and covered cells
Adjacent columns with the same style may be written once with
table:number-columns-repeated. Adjacent rows with the same content and
style, and no vertically merged cells, may be written once with
table:number-rows-repeated. Adjacent cells with the same content and
style that are not merged may be written once with
table:number-columns-repeated. All three default to 1.
A merged cell is a table:table-cell with
table:number-columns-spanned and/or
table:number-rows-spanned greater than 1 (both default to 1). Every grid
position it covers must still be present as a
table:covered-table-cell, so each row always has the full number of
cell elements.
<table:table table:name="Table1" table:style-name="Table1">
<table:table-column table:style-name="Table1.A" table:number-columns-repeated="3"/>
<table:table-header-rows>
<table:table-row>
<table:table-cell table:number-columns-spanned="2" office:value-type="string">
<text:p>Name</text:p></table:table-cell>
<table:covered-table-cell/>
<table:table-cell office:value-type="string"><text:p>Total</text:p></table:table-cell>
</table:table-row>
</table:table-header-rows>
<table:table-row>
<table:table-cell office:value-type="float" office:value="2"><text:p>2</text:p></table:table-cell>
<table:table-cell office:value-type="float" office:value="3"><text:p>3</text:p></table:table-cell>
<table:table-cell office:value-type="percentage" office:value="0.50"><text:p>50%</text:p></table:table-cell>
</table:table-row>
</table:table>
Cells
| Attribute | Values | Meaning |
|---|---|---|
office:value-type | float, percentage, currency, date, time, boolean, string, void | The type of the cell’s value. The value is in the attribute for its type (below); the paragraphs inside the cell are the value as displayed. |
office:value | number | Value of a float, percentage or currency cell. |
office:currency | currency, such as USD | Currency of a currency cell. |
office:date-value | date or date-time | Value of a date cell. |
office:time-value | duration, such as PT03H30M00S | Value of a time cell. |
office:boolean-value | true, false | Value of a boolean cell. |
office:string-value | text | Value of a string cell when it differs from the displayed text. |
table:formula | prefix, colon, formula text | A formula. The namespace bound to the prefix says which formula language is used; with no prefix it is OpenFormula (urn:oasis:names:tc:opendocument:xmlns:of:1.2). A producer must write a prefix whenever the formula itself starts with something that looks like a name and a colon. |
table:number-columns-spanned, table:number-rows-spanned | positive integer, default 1 | How many columns and rows the cell covers. |
table:number-matrix-columns-spanned, table:number-matrix-rows-spanned | positive integer | Size of the matrix (array) a matrix formula fills. |
table:number-columns-repeated | positive integer, default 1 | How many times the cell repeats to the right. |
table:style-name | style name | A cell style (family table-cell). If missing, the row’s table:default-cell-style-name is used, then the column’s, then the default style of the table-cell family. |
table:content-validation-name | name | A validity check (table:content-validation) the cell must pass; without it the cell may hold anything. |
table:protected | true, false (default) | The cell cannot be edited. |
table:protect | true, false (default) | Old name for table:protected; deprecated. |
xhtml:about, xhtml:property, xhtml:content, xhtml:datatype | RDFa values | Metadata about the cell in RDFa form: subject, property, value and its datatype. |
xml:id | ID | An identifier, used by RDF metadata. |
When a row and a column both give a default cell style, the row’s wins.
Table, column and row attributes
| Attribute | On | Values | Meaning |
|---|---|---|---|
table:name | table | text | The table’s name, used in cell addresses. |
table:style-name | table, column, row | style name | A style of family table, table-column or table-row. |
table:default-cell-style-name | column, row | style name | Cell style for cells in this column or row that have none of their own. |
table:number-columns-repeated | column | positive integer, default 1 | How many adjacent columns this element describes. |
table:number-rows-repeated | row | positive integer, default 1 | How many identical adjacent rows this element stands for. |
table:visibility | column, row | visible (default), collapse, filter | Shown; hidden; hidden because a filter excludes it. |
table:display | row group, column group | true (default), false | Whether the group is shown. |
table:is-sub-table | table | true, false (default) | A nested table that fills its cell completely: no other content in the cell, its borders merge with the cell’s, and it has no style of its own. A nested table that is not a subtable keeps its own borders and the cell’s padding. |
table:template-name | table | name | A table template (table:table-template, see Styles). |
table:use-first-row-styles, table:use-last-row-styles, table:use-first-column-styles, table:use-last-column-styles | table | true, false (default) | Apply the template’s first-row, last-row, first-column or last-column cell style. |
table:use-banding-rows-styles, table:use-banding-columns-styles | table | true, false (default) | Apply the template’s even and odd row (or column) styles. |
table:print | table | true (default), false | Whether the table is printed. A table that is not displayed is not printed either. |
table:print-ranges | table | cell range address list | The cells to print; without it, the non-empty part of the table is printed. |
table:protected | table | true, false (default) | The table is protected. Its cells are then protected only if their cell style has style:cell-protect other than none. |
table:protection-key | table | string (binary data) | The value needed to remove protection: with a digest algorithm, the hash of the password as UTF-8 bytes. |
table:protection-key-digest-algorithm | table | IRI, default http://www.w3.org/2000/09/xmldsig#sha1 | How the key was made. Readers must support …xmldsig#sha1 and …xmldsig#sha256; writers should use SHA-256. Other procedures are implementation-defined. |
Cell addresses
Formulas, print ranges and other attributes refer to cells by address:
- A cell address is the table name, a dot, the column letters and the row number:
Table1.B3. Column A is 1, B is 2, Z is 26, AA is 27, AB is 28; row 1 is the first row. - A cell in a subtable is the address of the cell holding the subtable, a dot, then the address inside the subtable.
- A table name containing spaces, dots or apostrophes is put in apostrophes, with
any apostrophe in it doubled:
'Bob''s table'.A1. - An absolute address puts
$before the table name, column and row:$Table1.$B$3. Absolute and relative parts may be mixed; an absolute address must include the table name. Where the difference does not matter the dollar signs may be left out. - A cell range is two cell addresses joined by a colon, top left first:
Table1.A1:Table1.C4. A single cell is also a range. - A row range leaves out the column letters, a column range leaves out the row numbers.
- A range list is cell or range addresses separated by white space.
What a reader does with a reference to a cell that is not in the file is up to the implementation.
Linked tables, scenarios and detective marks
These come from the spreadsheet side of the model, but are allowed on any table.
| Element | Meaning | Attributes and values |
|---|---|---|
table:table-source | The table is a copy of a table in another file. | xlink:href (the file), xlink:type="simple", xlink:actuate="onRequest"; table:table-name (the source table; the first table if missing); table:mode = copy-all (formulas and styles, the default) or copy-results-only; table:filter-name and table:filter-options (the source’s file type and its settings, implementation-dependent); table:refresh-delay (a duration between automatic refreshes) |
table:scenario | Makes this table a scenario table: its ranges replace the same ranges of the nearest ordinary table before it. Where several scenarios cover a range the user picks one; only one can be applied to a range at a time. | table:scenario-ranges (range list); table:is-active; table:display-border (default true) and table:border-color; table:copy-back (copy data back when another scenario is chosen, default true); table:copy-formulas (true default: formulas, false: only results); table:copy-styles (default true); table:protected (only applies if the table is protected); table:comment |
table:cell-range-source | In the first cell of a range: the range is linked to a named or database range in another file. | table:name (the source range), xlink:href, xlink:type, xlink:actuate, table:filter-name, table:filter-options, table:last-column-spanned and table:last-row-spanned (the range’s last known size), table:refresh-delay |
table:detective | In a cell: which relations to other cells are shown. | contains table:operation and table:highlighted-range |
table:operation | One detective operation. | table:name = trace-dependents, remove-dependents, trace-precedents, remove-precedents, trace-errors; table:index (order of the operations) |
table:highlighted-range | A range highlighted by those operations or because it holds an error or invalid data, as it was when last worked out. | table:cell-range-address; table:direction = from-another-table, to-another-table, from-same-table; table:contains-error (default false); table:marked-invalid (used alone) |
Precedents are the cells a formula uses; dependents are the cells whose formulas use this one. How highlighting looks is up to the program.
Formula settings
A program that evaluates table:formula takes these host settings from
the document’s calculation settings (table:calculation-settings), with
these defaults:
| Property | Attribute | Default |
|---|---|---|
| HOST-CASE-SENSITIVE | table:case-sensitive | true |
| HOST-PRECISION-AS-SHOWN | table:precision-as-shown | false |
| HOST-SEARCH-CRITERIA-MUST-APPLY-TO-WHOLE-CELL | table:search-criteria-must-apply-to-whole-cell | true |
| HOST-AUTOMATIC-FIND-LABELS | table:automatic-find-labels | true |
| HOST-USE-REGULAR-EXPRESSIONS | table:use-regular-expressions | true |
| HOST-USE-WILDCARDS | table:use-wildcards | false |
| HOST-NULL-YEAR | table:null-year | 1930 |
| HOST-NULL-DATE | table:null-date | 1899-12-30 |
| HOST-LOCALE | – | implementation-defined |
| HOST-ITERATION-STATUS | table:status | disable |
| HOST-ITERATION-MAXIMUM-DIFFERENCE | table:maximum-difference | 0 |
| HOST-ITERATION-STEPS | table:steps | 100 |
Source
OpenDocument Version 1.3, OASIS Standard, 27 April 2021, part 3 (schema), sections
9.1 to 9.3 and the table: and office: attributes in
chapter 19; read in full for this page.