Log in

Basically, expressions in ODS templates work quite similarly than their counterparts in ODT templates. Expressions in ODS templates allow to inject, in a given cell, the result of evaluating a Python expression. That being said, the syntax varies from ODT expressions. As already mentioned in the POD introduction, any cell whose content is of the form


will be interpreted by POD as a Python expression, to be evaluated in the current context. This syntax corresponds to an ODS formula whose result is a string being expressed as a string literal, surrounded by double quotes. Any cell that does not conform to this syntax will be left as-is in the ODS result.

ODS expressions are typed

ODT expressions must produce strings, because, basically, a word processor is about manipulating text. If one of your ODT expressions does not produce a string, POD will convert its result to a string. ODS expressions behave differently. Because ODS cells can hold values from various types, ODS expressions can evaluate to such typed values. The following table makes the correspondance between the Python types (as results of ODS expressions) and the types of the ODS cells that will hold those values.

If the ODS expression evaluates to...The ODS cell hosting that value will have type...
an int or float value float
a long value (Python 2) float
an instance of class datetime.datetime
(from the Python standard library)
an instance of third-party class DateTime.DateTime date
anything else string

Because POD produces such typed cells in ODS results, you can apply the appropriate formatting options in LibreOffice Calc to render your value exactly how you want it to be rendered. For example, you may have defined a cell containing this formula:

Suppose the start attribute of the info object holds a DateTime instance with value 1975/12/11 12:12, and you have selected formatting options as shown hereafter (this is achieved by right-clicking on the ODS cell containing the formula):

When rendering the ODS template, the resulting cell will contain a real date value rendered that way: