@@ -90,6 +90,10 @@ tests =
90
90
91
91
testGroup " Reader/inline strings"
92
92
[ testCase " Can parse row with inline strings" inlineStringsAreParsed
93
+ ],
94
+
95
+ testGroup " Reader/floats parsing"
96
+ [ testCase " Can parse untyped values as floats" untypedCellsAreParsedAsFloats
93
97
]
94
98
]
95
99
@@ -205,4 +209,23 @@ inlineStringsAreParsed = do
205
209
]
206
210
expected @==? (items ^.. traversed . si_row . ri_cell_row)
207
211
212
+ untypedCellsAreParsedAsFloats :: IO ()
213
+ untypedCellsAreParsedAsFloats = do
214
+ -- values in that file are under `General` cell-type and are not marked
215
+ -- as numbers explicitly in `t` attribute.
216
+ items <- runXlsxM " data/floats.xlsx" $ collectItems $ makeIndex 1
217
+ let defCell v = def
218
+ { _cellValue = Just v
219
+ }
220
+ expected =
221
+ [ IM. fromList [ (1 , def & cellValue ?~ CellDouble 12.0 ) ]
222
+ , IM. fromList [ (1 , def & cellValue ?~ CellDouble 13.0 ) ]
223
+ -- cell below has explicit `Numeric` type, while others are all `General`,
224
+ -- but sometimes excel does not add a `t="n"` attr even to numeric cells
225
+ -- but it should be default as number in any cases if `t` is missing
226
+ , IM. fromList [ (1 , def & cellValue ?~ CellDouble 14.0 & cellStyle ?~ 1 ) ]
227
+ , IM. fromList [ (1 , def & cellValue ?~ CellDouble 15.0 ) ]
228
+ ]
229
+ expected @==? (_ri_cell_row . _si_row <$> items)
230
+
208
231
#endif
0 commit comments