Skip to content

feat(xlsx): report numeric display overflow - #323

Merged
goworm merged 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/detect-xlsx-numeric-overflow
Aug 30, 2026
Merged

feat(xlsx): report numeric display overflow#323
goworm merged 1 commit into
iOfficeAI:mainfrom
y4ho0:agent/detect-xlsx-numeric-overflow

Conversation

@y4ho0

@y4ho0 y4ho0 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a machine-readable numeric_overflow warning in the Format bucket when an explicit, width-stable xlsx numeric or date display cannot fit its visible column or merged-range width
  • honor effective cell, row, column, and base styles; hidden surfaces; merged cells; shrinkToFit; Show Formulas; 1900/1904 date semantics; and remaining --limit capacity
  • conservatively skip General and unresolved formats, rotated or shrink-to-fit cells, ambiguous 1904 date formulas, and negative 1900 elapsed values where widening is not a valid fix

Scope

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 existing ExcelHandler.SheetShift.cs:538 CS8602 warning appeared during the full rebuild)
  • dotnet build src/officecli/officecli.csproj --configuration Release --no-restore (passed, 0 errors)
  • public ViewAsIssues runner 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 limits
  • CLI black box: view issues --type numeric_overflow --json reported the narrow formatted value at /Sheet1/A1 with a machine-readable width suggestion
  • git diff --check

@y4ho0
y4ho0 marked this pull request as ready for review August 16, 2026 21:02
@PeterZZZ

Copy link
Copy Markdown

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: view html on a real workbook came back ~108 KB (truncated at our 64 KiB capture cap before the model ever saw the end of it), versus ~1.5 KB for view issues. In runs where an agent pulled the full HTML dump, on average ~190k tokens per run were replay of that single dump. A trustworthy numeric_overflow check in the Format bucket is exactly what lets automated audits stay on the compact path, so we're glad to see this.

One suggestion in that same spirit — output size scaling. If I'm reading CheckAllNumericOverflow right, findings are emitted per cell. The common real-world shape of this defect is columnar: one narrow column under a numeric/date format overflows in every data row, so a 5,000-row sheet yields 5,000 findings that all carry the same actionable fix (suggest.width=N on the same column). That has two costs for the audit use case:

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 suggest.width for the whole column), and one representative display value? Roughly:

path:       /Sheet1/A
message:    numeric overflow in 4,832 cells (A2..A5000); worst '1,234,567.89' at 11.0pt needs 15.2 width, column A is 8.43
suggestion: suggest.width=16; widen column A to at least 16

Merged-range findings are already effectively per-range and could stay as they are. This bounds output by columns instead of cells, and --limit capacity then buys distinct fixes instead of repetitions of one.

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 numeric_overflow as soon as it ships in a release.

@y4ho0

y4ho0 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

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 --limit, while a per-column aggregate can retain the worst required width and expose distinct fixes across sheets.

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.

@goworm
goworm merged commit 5c791a8 into iOfficeAI:main Aug 30, 2026
goworm added a commit that referenced this pull request Aug 30, 2026
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.
@y4ho0
y4ho0 deleted the agent/detect-xlsx-numeric-overflow branch September 8, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants