odftoolkit icon indicating copy to clipboard operation
odftoolkit copied to clipboard

Fixing the roundtrip of Cell FormatCode (implementation-defined) for Currency

Open svanteschubert opened this issue 7 months ago • 0 comments

A FormatCode is being used in ODF for Cells, which is implementation-defined by the ODF applications: image

from see https://docs.oasis-open.org/office/OpenDocument/v1.4/OpenDocument-v1.4-part4-formula.html#TEXT

For instance,

  1. Excel defines it here: https://support.microsoft.com/en-us/office/review-guidelines-for-customizing-a-number-format-c0a1d1fa-d3f4-4018-96b7-9c9354dd99f5 and their example of a FormatCode "[Blue]#,##0.00_);Red;0.00;"sales "@" will result in a positive integer being blue 1234.5 will be displayed as 1.234.50 in blue, while the same as a negative number with brackets in red. Any string data will receive a sales prefix. I was able to add this string in LibreOffice 24.8.6.2 in the GUI for custom formatting of a cell, and it worked!

  2. LibreOffice defines it here: https://help.libreoffice.org/24.8/en-GB/text/shared/01/05020301.html?&DbPAR=CALC&System=WIN

Reading the above documentation, the # is an optional integer, which will be omitted when not present in the number. From my understanding, the example #0.0 does not make sense in the text, only #.0, where the number .9 will remain without a leading 0. Please correct me if I misinterpreted this.

In our test class TableCellTest.java, the test testGetSetCurrencyFormat() was disabled as it was not being round-tripped correctly.

Please consider that the FormatCode has been changed, and the latest version of LibreOffice should be used for updating/validating the test documents.

svanteschubert avatar May 13 '25 11:05 svanteschubert