Closed lrakauskas closed 11 months ago
I've just came here to report the same issue... As I had to create small work-around for it:
....
$rowIterator = $sheet->nextRow($headers, Excel::KEYS_FIRST_ROW, true);
// and then $rowIterator is basically
/** @var iterable<int, array<string, array{v: mixed, t: string, o: mixed}>> where `o` is original value before any casting */
So you can create whatever casting logic you want 😉
I spent some time on this so I will try to write-up my findings.
Problem is not related only to int values but to all numeric/numeric like values which can be found xlsx cell value.
Examples of problematic values:
01
-> casted into (int) 1
01.4
-> casted into (float) 1.4
7E792223
-> scientific notation, casted into INF
-1354.98879e+37436
-> scientific notation, casted into -INF
-1354.98879e+1
-> scientific notation, casted into -13549.8879
01e1
-> scientific notation, casted into (int)10
If in Excel cell value is "013",
$sheet->nextRow()
would return such cell as(int) 13
, which is not correct.Problem stems from https://github.com/aVadim483/fast-excel-reader/blob/main/src/FastExcelReader/Sheet.php#L170
For the sake of testing, you can simply run the following:
Is there a way to skip automated cell type casting so that original cell values are returned? Or is there a way to force certain column to always return
string
?