Open olafklinke opened 1 month ago
Remark: I have not sanity-checked my PR, it is just the bare minimum to make the changes compile as a proof-of-concept. In particular, the TH-generated _CellDouble
prism is still missing.
Thanks @olafklinke I'll try to find time for that PR
I noticed that I neglected to adjust the test suite. But a simple s/CellDouble/CellDecimal/g
for each file in test/
makes all tests pass.
Would you mind fixing the tests?
Apologies, the last commit that should have fixed the test apparently did not change any files. I added a 9th commit to my fork. How do I update the PR to include these commits? Or does the PR update itself?
It does but unfortunately CI run doesn't get automatically approved (probably I need to do something about that)
If the OOXML spec really states that all numbers in spreadsheets are xsd:double then the real issue is not the conversion between decimal representation and CellDouble
but rather the fact that TimeOfDay
and Double
are in mismatch and do not properly round-trip: A second in a standard day is 1/86400 which is not a dyadic rational and hence neither representable in Double
nor does it have a finite decimal expansion.
Oh, shoot, I didn't check the XSD spec, thanks. OOXML spec doesn't really state that. That was only for cached values and it seems I didn't check it all through...
Currently
xlsx
seems to build on the Data.Text.Read module, which provide polymorphic functions likeThis is however used to parse a decimal number from the XML into a Double value (note that
CellDouble :: Double -> CellValue
) which for most values can not represent the rational number exactly. This is especially annoying when the decimal number represents aLocalTime
, because rounding errors can shift the time into a different day, thus affecting the displayed value quite a lot. My proposed change is thatCellValue
gets an additionalCellDecimal
constructor for implementing and testing therational
parsing toScientific
.CellDouble
is deprecated.To limit breakage, one could provide a view pattern named
CellDouble
that usesData.Scientific.toRealFloat
for the transition phase.