feat: Add usePlainNumberFormatForAllCells option to read numeric cells at full precision regardless of cell format - #1061
Open
vladislav-ishchenko wants to merge 1 commit into
Conversation
…s at full precision regardless of cell format
vladislav-ishchenko
force-pushed
the
plain-number-all-cells
branch
from
August 26, 2026 08:42
fb6219d to
5a5554a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1053.
What
New boolean read option
usePlainNumberFormatForAllCells(defaultfalse): 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 honors the option too, so a numeric header cell is named consistently with its own data cells.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, and ausePlainNumberFormat-only read pinning the boundary between the two options. The V1 tests go through thespark.read.excel(...)DSL so the option-key plumbing is exercised as well.