feat(xlsx): report numeric display overflow - #323
Conversation
|
Thanks for taking this on — this is Part 1 of #301, which we filed after measuring what whole-document HTML previews cost in an agent-driven audit loop: One suggestion in that same spirit — output size scaling. If I'm reading
Since the actionable fix granularity is per column (one width set), would you consider aggregating per (sheet, column): one finding carrying the affected-cell count and range, the worst-case cell (whose max required width is also the correct Merged-range findings are already effectively per-range and could stay as they are. This bounds output by columns instead of cells, and To be clear, this doesn't have to block this PR — the detection mechanics wouldn't change, only the emission, so it could equally be a follow-up. Either way we're looking forward to it landing: we pin the officecli version downstream, and we'll route our xlsx audit gates onto |
|
Thanks for the concrete scaling example. I agree that the actionable unit is the column: emitting one finding per cell lets a single narrow column consume the output and I’ll keep this PR focused on the detection mechanics that are already covered here, since changing finding paths and aggregation semantics would broaden it late in review. Once this lands, I’ll treat per-(sheet, column) aggregation as a separate follow-up with dedicated large-column and cross-sheet limit tests. |
The numeric-fit scan added in #323 deliberately skips General, because General adapts its display to the column. But that adaptation has a hard floor: Excel rounds to 11 significant digits and, once the integer part alone needs 12+, falls back to scientific notation NO MATTER how wide the column is. Verified against desktop Excel at width 20 -- 12345678901 renders in full, 123456789012 becomes 1.23457E+11 -- and re-checked at widths 14/16/18/20/24 with the same result. A delivered workbook shows a rounded number with no visual cue, and widening (the other scan's advice) does not help; applying an explicit format does. Reported as `general_precision_loss`, disjoint from `numeric_overflow` by construction: that one needs an explicit format, this one needs General. The suggestion is a number format, never a width. Kept quiet by two guards, both driven by a sweep over the sample corpus: - Only when the INTEGER part needs 12+ digits. Flagging on significant digits alone reported 11,397 cells across 89 workbooks -- almost all float artifacts on computed columns (46551.299999999996), which General rounds back to a perfectly ordinary 46551.3. - Only when a number format can actually fix it (<= 15 significant digits and below 1e15). A pivot aggregate of 5.556714093664954E+31 has no positional rendering at any width or format. After both guards: 0 findings across those 89 real workbooks, while the 12/13/15-digit fixtures still report. Applying the suggested numberFormat and re-rendering in real Excel shows the full digits and clears the scan. A workbook with no stylesheet is treated as all-General rather than skipped -- it cannot carry a number format, so it is the most General-heavy case there is, and the sibling scan's early return would have blinded this one to it.
Summary
numeric_overflowwarning in the Format bucket when an explicit, width-stable xlsx numeric or date display cannot fit its visible column or merged-range widthshrinkToFit; Show Formulas; 1900/1904 date semantics; and remaining--limitcapacityScope
Part 1 of #301 only. PPTX layout and spacing checks remain out of scope.
Refs #301
Validation
dotnet run --project tests/OfficeCli.NumericFit.Tests/OfficeCli.NumericFit.Tests.csproj --configuration Release --no-restore(passed; only the existingExcelHandler.SheetShift.cs:538CS8602 warning appeared during the full rebuild)dotnet build src/officecli/officecli.csproj --configuration Release --no-restore(passed, 0 errors)ViewAsIssuesrunner covers narrow and adequate widths, General and explicit formats, formulas, ISO and 1904 dates, built-ins 45-48, style inheritance, merges beyond renderer caps, hidden surfaces,shrinkToFit, non-finite values, and exact/bucket limitsview issues --type numeric_overflow --jsonreported the narrow formatted value at/Sheet1/A1with a machine-readable width suggestiongit diff --check