pjfanning opened a new pull request, #1485: URL: https://github.com/apache/poi/pull/1485
Follow-ups to #1473, from a review after it was merged. **CellFormat no longer throws for a large improper fraction.** `writeFraction` threw `IllegalArgumentException` when the numerator did not fit in an int. Only `DataFormatter`'s wrapper caught it, so other callers of `CellFormat`, e.g. `ToHtml`, still failed. The fraction is now worked out for the part after the whole number, and the whole number is added to the numerator as a `BigInteger`. `?/?` shows 3e9+0.5 as `6000000001/2`, the same as `DataFormatter`'s `FractionFormat`. `??\=/=??` now keeps its text for these values (`6000000001=/=2`) instead of falling back to `6000000001/2`. **DataFormatter does not probe CellFormat any more.** - The fraction-with-text path probed with 1.25. In a conditional or multi-section format that can land in a different section from the real values. - The literal-text / zero-before-optional-digit path (`0\.0`, `60#########`) still probed with `cellValue`, so the cached format depended on which cell came first. Both paths now return the `CellFormatWrapper` without probing. The wrapper falls back for each value that fails, and creates the fallback the first time it is needed instead of for every format. **A CellFormat failure is logged at warn the first time for a format**, and at debug after that. #1473 logged every failure at debug, which hid CellFormat bugs. **One denominator-digit limit.** The fallback for a fraction with text used `FractionFormat`'s 4-digit limit while `CellFormat` allows 9, so cells with the same format could show different precision. The 9 is now `SimpleFraction.MAX_DENOMINATOR_DIGITS`, and `FractionFormat` has a package-private constructor that takes the limit. Plain fraction formats keep the 4-digit limit. **SimpleFraction:** the numerator-overflow early return and the overflow throw are merged into one check. The tests from #1473 that expected the throw, or the fallback without the text, are updated. Not changed: `# ?/?` (a proper fraction) shows values above `Long.MAX_VALUE` as 9223372036854776000, because `formatValue` casts the whole number to a long. That was already the case before #1473. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
