Introduction
ODS is the spreadsheet of the OpenDocument Format (ODF), the open standard from OASIS that is also ISO/IEC 26300. It is the default format of LibreOffice Calc and is read and written by Excel and Google Sheets. It is built the same way as the ODT text document.
.ots is a spreadsheet template, and .fods a flat, single XML
file version.
Structure
An ODS file is a ZIP archive whose first, uncompressed
entry is mimetype, containing
application/vnd.oasis.opendocument.spreadsheet. The sheets are in
content.xml: each sheet is a table:table made of
table:table-row elements holding table:table-cell elements.
A cell gives its type and value as attributes, such as
office:value-type="float" and office:value="42", its formula
in table:formula, and the displayed text in a paragraph inside it.
Repeated empty rows and cells are written once with a repeat count. See
Package and tables for every
element, attribute and value type.
Not described
ODF is an open standard, so every item here is work not yet done.
Known, not yet covered
- Reference and viewer: the table template (
table:table-template, Part 3 section 16.20) is listed (name, corner columns, the style of each part) and applied to a table that names it withtable:template-nameand switches parts on with thetable:use-*-stylesflags: first column, last column, first row, last row, banded rows, banded columns, then the body, the first match winning, and the cell’s own style going over the template’s. Part 3 does not say which of the two rows of banding is first or how the corner cells are chosen beyond the four corner attributes; the viewer takes the first row after the header as odd and a corner’s part from theroworcolumnvalue. The viewer lists scenarios, linked tables (table:table-source,table:cell-range-source), formula dependencies, the detective marks (table:dependencies,table:detective) and thetable:error-macroof a validation with their attributes in the Scenarios, linked data and audit marks section, and, in the Database ranges, Pivot tables, Tracked changes and Calculation settings sections, the filter conditions (table:filter-and,table:filter-or,table:filter-condition), sort keys, subtotal rules, pivot fields with their subtotals and hidden members, spreadsheet changes with the cell content before, and the null date and iteration settings. - Reference: formulas: OpenFormula, Part 4 of ODF 1.3, which gives the syntax and every function.
- Reference: what each text property and paragraph property does
(the styles page lists the attribute names; their meanings are shared with
ODT). The viewer draws, for every cell style and for the
text:spanstyles inside a cell, the colour, weight, slant, underline, strike-through, size, font family, case, small capitals, letter spacing and superscript or subscript, the fill colour and picture (style:background-image, section 17.3), the four borders and two diagonals, the horizontal alignment (or the one the value type gives), the vertical alignment, wrapping, shrinking, rotation, the left margin of the paragraph, merged areas, column widths and row heights, hidden rows and columns, the styles that a conditional format (calcext:conditional-format) or astyle:mapcondition applies to a cell, double borders (the width fromstyle:border-line-width), text shadow, outline, emphasis marks, embossed and engraved relief, and hidden text (text:display="none", left out of the cell). It does not draw blinking text (style:text-blinking; it is read, not animated), the other paragraph properties (line height, tab stops, hyphenation, widows and orphans, breaks), which have no effect in one cell line. A conditional style that has its own number format (style:data-style-name) shows the value in that format, as LibreOffice does (samples/ods/cond-numfmt.fods).style:mapis read from automatic and named cell styles, and through the parent chain (samples/ods/cond-named.fods). - Viewer: a dropped
.ods(or flat.fods) is read by the ODF viewer: every sheet is a paged grid of the text the cells show (all rows and all columns), with every formula, named range, validation, comment, merged area, database range, pivot table, conditional format and tracked change listed in full. Each formula is shown as written, with its syntax (OpenFormulaof:, OpenOffice.orgoooc:or Excelmsoxl:), its reading form (=SUM(B2:B3)), the cell references and functions it uses, and the value the file cached; formulas are never evaluated. Cell styles are listed and drawn as above; the cell text is the text the producer saved, and when a cell has a value but no saved text the viewer builds the text from the cell’s number, percentage, currency, date, time, boolean or text data style (includingstyle:mapconditions and the language and country of the style), using the cell’s own style, else the default cell style of its row or column; a Number format check section counts the cells whose saved text equals what the data style gives; a chart is summarised (type, axes, series, data) and also drawn in the Charts drawn section for every chart object held in a sheet (on the sheet or anchored to a cell) and when its own object is opened (bar and column in clustered, stacked and percent forms, line, area, pie, ring, scatter, bubble, radar, filled radar and stock charts, from the chart’s table and styles; three-dimensional charts are drawn flat, and the layout is the viewer’s, not LibreOffice’s), and, with the shapes and pictures of a sheet (including adraw:frameholding a chart), placed on the grid at the cell their offset falls in, measured with LibreOffice’s default sizes (columns 2.26 cm, rows 0.45 cm; the viewer’s rows are a little taller than 0.45 cm), the grid being widened under a drawing that lies beyond the used cells; and a formula is read by a token reader, which flags unbalanced brackets and unknown characters and marks function names that are not among the 392 functions of OpenFormula chapter 6 (names of the formCOM.MICROSOFT.,ORG.or a country code are accepted as the nonstandard names of section 5.7); argument counts are not checked. The number format is not drawn over cells that already carry saved text.
Divergence from spec
The key programs are LibreOffice Calc, Apache OpenOffice Calc, Microsoft Excel and Gnumeric. Where the standard and the programs differ, this page follows what LibreOffice Calc writes and shows, since it is the reference producer of ODS.
- Function names. OpenFormula chapter 6 lists the standard functions, but LibreOffice keeps the
legacy and unknown names as written, in lower case (for example
chidist(instead ofLEGACY.CHIDIST(), so a file from LibreOffice can hold names the specification does not list; the viewer marks them without rejecting the file. - Display text. Part 1 describes the data styles but not the exact text. LibreOffice drops the grouping separators when a number has embedded text, pads a whole number in a fraction format with figure spaces (U+2007), and chooses month and day names from the language and country of the style; the viewer’s text was compared with LibreOffice’s for 60 cells and matches.
- Default cell styles. Part 1 (attribute
table:default-cell-style-name) says cells with notable:style-nameuse the column’s or row’s default cell style. LibreOffice Calc writes the attribute but did not apply it to every such cell when it re-saved a minimal file (coldefault.fodsin the samples folder and its LibreOffice re-save inlo-out), so the viewer follows the specification. - Cell looks. LibreOffice Calc draws no picture behind a cell (
style:background-image), nofo:text-transformand nofo:letter-spacing, and indents text byfo:margin-leftonly when the alignment is left; the viewer draws all four as the specification describes them. Everything else insamples/ods/paint.fodslooks the same in LibreOffice’s PNG (samples/ods/lo-png/paint.png) and in the viewer’s drawing of the same file. - Locale. A data style with no
number:languageis shown by the program in its own locale (a Czech or Dutch Calc writes “PRAVDA” or “WAAR” for true, and decimal commas). In 1,593 spreadsheets (the Calligra test suite, the odfpy examples and LibreOffice’s own Calc test data), 101,431 saved cell texts equal what the viewer builds, none differs, 11,222 differ only in that locale case, and 282 are not checked (a date or time pattern taken from the locale,number:format-source="language"). The Number format check section counts these separately. Two more LibreOffice rules are followed: the General style (no decimal places) shows up to 15 significant digits, and a format with its own “-” text does not get the automatic minus. A cell whose style carries an unrounded saved value (for example a formula result inforecast.ets.add.fodscell B8) is shown by LibreOffice unrounded, as the viewer does. - Table templates. Part 3 section 16.20 describes
table:table-template, but LibreOffice Calc ignores it in a spreadsheet (samples/ods/template.fodsandlo-png/template.pngshow plain cells); the viewer applies it as the specification says. - Conditional styles. LibreOffice ignores
style:mapon a cell style when the sheet also hascalcext:conditional-formatelements; the viewer applies both. A conditional style with its own number format replaces the saved text with the value in that format.style:mapis read from automatic and named cell styles. - Formulas. The value a formula cached stays the shown value (Part 4 section 3.5; LibreOffice does not recalculate an ODF file on load); the viewer never evaluates a formula.
- Text effects. LibreOffice Calc draws shadow, outline, emphasis marks, relief and double borders as the viewer
does (
samples/ods/effects.fods,lo-png/effects.png) but does not hidetext:display="none"runs in a cell; the viewer leaves them out. Blinking is not animated by either. - Locale date patterns. For a date or time style with
number:format-source="language"the specification leaves the pattern to the program’s locale; the viewer keeps the saved text for these 282 cells and does not rebuild them. LibreOffice takes the pattern from its own locale data, which is not identical to CLDR, so a pattern table built from CLDR could differ from the saved text of a real file. Measured against the corpus with Node’s CLDR data: of the 280 listed cells, 268 have no language in the style (the pattern belongs to the program that saved the file, which the file does not name), 4 (French) equal the CLDR short date, and 8 use a Buddhist, Japanese-era, Hebrew or Hijri calendar with native digits that CLDR’s four standard patterns do not reproduce. The viewer therefore shows the saved text. The Number format check section lists the first cells of this kind. - Saved text wins. The viewer shows the text the producer saved in
text:pand only rebuilds the text when it is missing, so a program that formats a value differently still shows its own result.
Sources
- OASIS, OpenDocument v1.3 Part 4: Recalculated Formula (OpenFormula) Format, chapters 5 and 6: part4-formula.
- OASIS, OpenDocument v1.3 Part 1, chapters 16.27 to 16.29 (data styles) and 19 (attributes): part1.
- LibreOffice Calc, run headless to write the expected display text of each cell and to re-save formulas.
Links
Software
- LibreOffice Calc – free office suite’s spreadsheet, which uses ODS by default (Windows, macOS, Linux)
- Microsoft Excel – Microsoft’s spreadsheet, which opens and saves ODS (Windows, macOS, web)
- Google Sheets – online spreadsheet that imports and exports ODS (web browsers)
- Apache OpenOffice Calc – the older free office suite’s spreadsheet (Windows, macOS, Linux)
Developers
Reference
- OASIS Open Document Format for Office Applications (OpenDocument) TC – the committee that maintains ODF, with the current specification
- OpenDocument 1.3 Part 3: OpenDocument Schema – the elements and attributes, including tables (section 9)