pjfanning opened a new pull request, #1604:
URL: https://github.com/apache/poi/pull/1604
Two existing problems in `CellFormat`, noticed while reviewing #1597
(neither is caused by that PR).
**Empty format string**
`CellFormat.getInstance("")` failed with an `IndexOutOfBoundsException`,
because the format has no sections. It is now shown as General.
**Section with a color and/or condition but no format specification**
For a format such as `0;[Red]`, the second section failed to parse
(`Unsupported [] format block`) and was dropped, so applying the format to a
negative number threw an `IllegalStateException`. `CellFormatPart` now takes
such a section as General with that color/condition, i.e. `[Red]` is handled as
`[Red]General`. This also covers `[>10]`, `[Red][>10]` and `new
CellFormatPart("[Red]")` directly.
I chose General because Excel rewrites a format code of `[Red]` to
`[Red]General` when it is entered in the Format Cells dialog. I have not
checked how Excel renders a file that contains the literal code `0;[Red]`, so
that choice (rather than showing nothing) is open to review.
**Tests**
New tests `testEmptyFormat` and `testSectionWithoutSpecification` in
`TestCellFormat`. Run locally: `org.apache.poi.ss.format.*`,
`TestDataFormatter` and `TestHSSFDataFormatter`, all passing. The full test
suite is left to CI.
This touches different lines from #1597, though both add tests to
`TestCellFormat`.
🤖 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]