pjfanning opened a new pull request, #1398: URL: https://github.com/apache/poi/pull/1398
Adds `TestDataFormatterAgainstExcel`, which checks `DataFormatter` against output computed by Excel rather than against hand-written expectations. ## Where the expected values come from Several sample workbooks in `test-data/spreadsheet` contain `TEXT(value, format)` formulas. Their results were cached when Excel saved the file, so each cached string is Excel's own rendering of that value and format. Until now only `CellFormat` (`TestCellFormatPart`) was tested against these workbooks; `DataFormatter` never was. All the workbooks used were last saved by Microsoft Excel (Mac Excel 12/16 and Windows Excel 14, according to the app properties): `NumberFormatTests.xlsx`, `GeneralFormatTests.xlsx`, `FormatConditionTests.xlsx`, `FormatChoiceTests.xlsx`, `ElapsedFormatTests.xlsx`, `DateFormatTests.xlsx`, `DateFormatNumberTests.xlsx` (1904 date system, which the test honours), `DateTimeToNumberTestCases.xls` and `59106.xlsx`. Two workbooks are left out: - `NumberFormatApproxTests.xlsx`: its exotic exponent formats are only checked approximately, even for `CellFormat`. - `FormatChoiceTests.xls`: it duplicates the `.xlsx` version. ## Known failures The test produces 569 dynamic tests. 297 currently match Excel. The other 272 are listed in the test, grouped by cause, as formats that never match (`UNSUPPORTED_FORMATS`) or as specific format and value pairs (`KNOWN_FAILURES`). Each listed case is asserted to *still differ* from Excel, so a fix that makes one match fails the test until the entry is removed. The list stays accurate and doubles as a to-do list. Gaps found, all confirmed by Excel's own output: - grouping separators not in the thousands position (`#,##`, `0,0`, …): Excel still groups by thousands - `?` placeholders outside fractions - fractions with text or `_` spacing between the digits - single-section conditional formats (`[<10]#" Wow"`), where the text is dropped when the condition applies - elapsed time formats such as `[s].000`, and negative elapsed times - `y` and `d-m-y` should give a 2-digit year - `a/p` and `A/P` should show a single letter - `General` should switch to scientific notation for very small numbers such as `1.1E-10` - seconds should be rounded rather than truncated when no fractional seconds are shown I haven't tried to fix these here. They're left for follow-up PRs. 🤖 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]
