Repository navigation
feat: Add usePlainNumberFormat=all to read numeric cells at full precision regardless of cell format - #1061
Conversation
fb6219d to
5a5554a
Compare
e591c61 to
fd04bc9
Compare
|
@nightscape glad to see #1040 and #1032 land — thanks. This one is ready for a look whenever you have a moment: rebased onto current Short version of the why: One thing I'd happily split out if you prefer a narrower diff: the PR also fixes |
|
Does it make sense to enhance |
|
@nightscape I'll push it to this PR: The extra boolean is gone. The Scala API keeps accepting |
…ision regardless of cell format
fd04bc9 to
ec80586
Compare
Closes #1053.
What
usePlainNumberFormatbecomes a three-state option parsed to an enum —false(default),true(unchanged:General/@-formatted cells) and the newall. Withall, every non-date numeric cell read into a string column — including cached numeric formula results — is rendered through the existingPlainNumberFormat(full precision, no scientific notation), ignoring the cell's number format. Date-formatted cells keep their formatted rendering, text cells stay verbatim, non-finite values keep POI's display rendering. V2 column naming honorsalltoo, so a numeric header cell is named consistently with its own data cells, andallselects the General number style on the write path liketruedoes. The Scala API keeps acceptingusePlainNumberFormat = true/= falsethrough an implicit conversion from Boolean;allisPlainNumberFormatMode.Allthere. Invalid values are rejected with the three allowed ones.usePlainNumberFormatonly registersPlainNumberFormatfor theGeneral/@format strings, so cells with an explicit number format still render their rounded/scientific display value:84.789under0.00reads as"84.79", and large formatted numbers read as scientific notation (#126, #771). Widening the registration isn't viable — the custom-format map is keyed by exact format string and shared with date rendering, and 2+-part;conditional formats bypass the map entirely — so the format-independent path branches on the cell instead.Also in this PR
PlainNumberFormatappended the unstrippedBigDecimal, so single-significant-digit values below 1e-3 gained a spurious trailing zero fromDouble.toString'sd.0E-xmantissa:0.0005read as"0.00050". It now appends the stripped value. Only that value class is affected (a sweep over 400k random doubles found no other differences), which meansusePlainNumberFormat=trueon a General-format cell holding0.0005now reads"0.0005"instead of"0.00050".Tests
Both engines (V1 + V2), including the
maxRowsInMemorystreaming path: explicit-format rounding vs. plain rendering, General-format scientific notation, text cells verbatim, date cells, a cached numeric formula result, the0.0005trailing-zero case, numeric header naming, ausePlainNumberFormat=trueread pinning the boundary betweentrueandall, and a parse suite for the three values and the rejection of anything else. The V1 tests go through thespark.read.excel(...)DSL so the option-key plumbing is exercised as well.