pjfanning opened a new pull request, #1412:
URL: https://github.com/apache/poi/pull/1412

   With this PR, `TestDataFormatterAgainstExcel` matches Excel for all 569 of 
its cases. Its known-failures lists are now empty.
   
   ## The change
   
   Excel shows quoted and escaped text, and `_` spacing, in a fraction format. 
`NumberFormatTests.xlsx` has:
   - `TEXT(23.75, "|#\:#/#|")` = `|23:3/4|`
   - `TEXT(3.75, "|#_#/#|")` = `|15 /4|`
   - `TEXT(23.75, "|#\:? ?0#/000")` = `|2:3  03/004`
   
   `DataFormatter` stripped that text, because `FractionFormat` doesn't handle 
it. Since #1406, `CellFormat` formats fractions as Excel does: it matches all 
3,540 fraction cells in `54686_fraction_formats.xls`. So any fraction format 
with text or spacing in it is now formatted by `CellFormat`, not just those 
with text around the `/`. Plain fractions (`# ?/?`, `# ??/??`) still use 
`FractionFormat`.
   
   ## Performance
   
   `DataFormatter.formatRawCellContents` over 100,000 random values. The 
figures are the average per value:
   
   | Format | trunk | this PR |
   |---|---|---|
   | `#\ #/#` | 13.1 µs | 5.7 µs |
   | `#"FRED" #/#` | 13.2 µs | 5.6 µs |
   | `#\ ??/??` | 14.1 µs | 5.8 µs |
   | `#\ ????/????` | 13.2 µs | 6.7 µs |
   | `#\ ??/?????????` | 13.8 µs | 7.2 µs |
   | `#\ ?????????/?????????` | 13.4 µs | 7.1 µs |
   | `# #/#`, `# ??/??` (unchanged, `FractionFormat`) | 13.2, 15.8 µs | 12.9, 
13.1 µs |
   
   `CellFormat` uses continued-fraction convergents, so even 9-digit 
denominators cost only a few dozen steps, and its formatters are cached.
   
   `FractionFormat` limits denominators to 4 digits, while `CellFormat` 
doesn't. As a result, the Tika-1132 column of `54686_fraction_formats.xls` (`#\ 
??/?????????`) now matches Excel. `TestFractionFormat.testTruthFile` had 
skipped that column ("for now") and now checks it.
   
   ## Test expectations changed
   
   `TestDataFormatter.testFractions` asserted that text in a fraction is 
stripped. Its expectations now show the text, following the rule in Excel's 
results above:
   
   | Format | Value | Was | Now |
   |---|---|---|---|
   | `#"  " #/#` | 321.321 | `321 1/3` | `321   1/3` |
   | `#"FRED" #/#` | 321.321 | `321 1/3` | `321FRED 1/3` |
   | `# \q#/#` | 321.321 | `321 1/3` | `321 q1/3` |
   | `0 "#"\#\#?/?` | 321.321 | `321 1/3` | `321 ###1/3` |
   
   `#   #/#` (unquoted spaces) and `#\ #/#` still give `321 1/3`.
   
   ## Tests
   
   Passing locally:
   - `poi`: `TestDataFormatter`, `TestFractionFormat`, `TestHSSFDataFormat`, 
`TestHSSFDataFormatter`, `TestBugs`, `org.apache.poi.ss.format.*`, 
`org.apache.poi.hssf.extractor.*`
   - `poi-ooxml`: `TestDataFormatterAgainstExcel` (569 of 569), 
`TestXSSFDataFormat`, `org.apache.poi.xssf.extractor.*`, 
`org.apache.poi.ss.tests.format.*`
   - forbidden-apis
   
   `TestXSSFBugs` passes apart from `stackoverflow23114397`, the font-metric 
width check that also fails locally on trunk.
   
   🤖 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]

Reply via email to