Skip to content

Parse Numbers as Scientific, not Double #176

Description

@olafklinke

Currently xlsx seems to build on the Data.Text.Read module, which provide polymorphic functions like

rational :: Fractional a => Text -> Either String (a,Text)

This 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 a LocalTime, because rounding errors can shift the time into a different day, thus affecting the displayed value quite a lot.
My proposed change is that

  1. CellValue gets an additional CellDecimal constructor for implementing and testing the rational parsing to Scientific.
  2. When this is established, CellDouble is deprecated.

To limit breakage, one could provide a view pattern named CellDouble that uses Data.Scientific.toRealFloat for the transition phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions