ddn.odf.table

Packaged .ods spreadsheet document model and APIs.

This module provides the spreadsheet model with sheets, rows, columns, and cells for reading, writing, and creating OpenDocument Spreadsheet files.

Spreadsheet constructs

Fully typed:

  • Sheets (table:table) with name, style, print ranges
  • Rows (table:table-row) with repetition, visibility, height
  • Columns (table:table-column) with repetition, width, visibility
  • Cells (table:table-cell) with typed values, formulas, styles
  • Cell value types: string, float, percentage, currency, boolean, date, time, void
  • Formulas with namespace, expression, cached value
  • Named expressions / named ranges
  • Column/row repetition without forced expansion

Preservation-first:

  • Filters, validations, database ranges
  • Data pilot tables, conditional formatting
  • Suite-specific extension elements

Types 8

Cell value type discriminant.

Maps to office:value-type attribute in ODF.

VOID
STRING
FLOAT
PERCENTAGE
CURRENCY
BOOLEAN
DATE
TIME

Represents a cell formula with namespace, expression, and cached result.

Formulas are preserved as-is without evaluation. The cached value and type are retained for round-trip fidelity.

Fields
string expression
string namespace_
string cachedValue
CellValueType cachedType
Methods
bool hasFormula() @safe pure nothrow constReturns `true` if this cell has a formula.

Represents a single table cell.

Cells carry a typed value, optional formula, style reference, and repetition count. The columnsRepeated field maps to table:number-columns-repeated and indicates how many logical columns this cell occupies (default 1).

Fields
CellValueType valueType
string value
string stringValue
string currency
string dateValue
string timeValue
string booleanValue
CellFormula formula
string styleName
int columnsRepeated
XmlElement rawElement
Methods
bool isEmpty() @safe pure nothrow constReturns `true` if this cell is empty (void with no formula).
int repeatCount() @safe pure nothrow constReturns the effective number of columns this cell spans.

Represents a table column declaration.

Columns are separate from rows in ODF. The columnsRepeated field allows declaring multiple identical columns without repeating the element.

Fields
int columnIndex
int columnsRepeated
string styleName
string defaultCellStyleName
bool isVisible
Methods
int repeatCount() @safe pure nothrow constReturns the effective number of columns declared.

Represents a table row.

Rows contain cells and may be repeated via number-rows-repeated.

Fields
int rowsRepeated
string styleName
bool isVisible
string defaultCellStyleName
Methods
int repeatCount() @safe pure nothrow constReturns the effective number of rows this row represents.
int totalCellCount() @safe pure nothrow constReturns the number of logical cells (summing repetitions).

Represents a named expression or named range.

Named ranges map a name to a formula expression (usually a range reference like $Sheet1.$A$1:.$C$10).

Fields
string name
string expression
string baseCellAddress
string namespace_

Represents a single sheet within a spreadsheet document.

Sheets contain rows, column declarations, and optional named expressions. Rows and columns are stored sparsely — repeated structures are not expanded.

Fields
string name
string styleName
string printRanges
NamedExpression[] namedExpressions
OdfSheetChange trackedChanges
XmlElement[] unknownElements
Methods
size_t rowCount() @safe pure nothrow constReturns the number of rows in this sheet.
bool isEmpty() @safe pure nothrow constReturns `true` if this sheet has no rows.

Represents the office:spreadsheet body of an .ods document.

Contains all sheets and provides access to named expressions defined at the document level.

Fields
NamedExpression[] namedExpressions
XmlElement[] unknownElements
Methods
size_t length() @safe pure nothrow constReturns the number of sheets.
bool isEmpty() @safe pure nothrow constReturns `true` if there are no sheets.
const(SpreadsheetSheet) * findSheet(string name) @trusted pure nothrow constFinds a sheet by name.

Functions 21

fnSpreadsheetSheet parseSheet(XmlElement tableElement)Parses a `table:table` XML element into a `SpreadsheetSheet`.
fnOdfSpreadsheetBody parseSpreadsheetBody(XmlElement spreadsheetElement)Parses an `office:spreadsheet` XML element into an `OdfSpreadsheetBody`.
fnOdfSpreadsheetBody emptySpreadsheetBody() @safe pure nothrow @nogcCreates an empty `OdfSpreadsheetBody`.
fnCellFormula parseFormula(string formulaAttr) @safe pure nothrowParses a `table:formula` attribute value into a `CellFormula`.
fnstring cellValueTypeString(CellValueType t) @safe pure nothrowConverts a `CellValueType` to its ODF attribute string.
fnCellValueType parseCellValueType(string s) @safe pure nothrowParses an `office:value-type` string into a `CellValueType`.
private fnint toInt(string s) @safe pure nothrow
private fnptrdiff_t indexOf(string s, char c) @safe pure nothrow
private fnauto parseXmlForTest(string xml)
fnstring serializeSpreadsheetBody(const ref OdfSpreadsheetBody body)Serializes an `OdfSpreadsheetBody` to an `office:spreadsheet` XML string.
private fnvoid serializeSheetNode(XmlElement parent, ref const SpreadsheetSheet sheet)
private fnvoid serializeCellNode(XmlElement parent, ref const SpreadsheetCell cell)
private fnstring intToStr(int v)
fnSpreadsheetCell stringCell(string value, string styleName = "") @safe pure nothrowCreates a cell with a string value.
fnSpreadsheetCell floatCell(string value, string styleName = "") @safe pure nothrowCreates a cell with a float value.
fnSpreadsheetCell formulaCell(string formulaNs, string formulaExpr, string cachedValue = "", CellValueType cachedType = CellValueType.VOID) @safe pure nothrowCreates a cell with a formula.
fnSpreadsheetRow row(SpreadsheetCell[] cells...) @safe pure nothrowCreates a row from cells.
fnSpreadsheetColumn column(int repeated = 1, string styleName = "") @safe pure nothrowCreates a column declaration.
fnSpreadsheetSheet sheet(string name, SpreadsheetRow[] rows_ = null, SpreadsheetColumn[] cols = null) @safe pure nothrowCreates a sheet with the given name, rows, and columns.