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

   Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=60895
   
   ### Background
   
   The three reports on this bug are all the same artefact: after 
`CellUtil.setCellStyleProperty(cell, DATA_FORMAT, …)` (or `ROTATION`, or 
`RegionUtil.setBorder*`) on a cell with the default style, the new style 
referenced a *new* fill `<patternFill><fgColor indexed="64"/><bgColor 
indexed="64"/></patternFill>` and a *new* border with a colour on every side, 
with `applyFill`/`applyBorder` set (comment 5's XML). Excel showed such cells 
white inside banded tables / conditional formatting (comments 0 and 4) and 
black while editing (comment 6, = bug 69463).
   
   #1337 (bug 69463) already removed the colours from the fill. This PR makes 
the created style reference the workbook's **existing** default fill 0 and 
border 0, so nothing is added and nothing is overridden:
   
   - **`XSSFCellStyle.setFillPattern(NO_FILL)`** used to *unset* `patternType`, 
giving `<patternFill/>`. `XSSFCellFill.equals` (property based since bug 60845) 
treats a null pattern as different from `NONE`, so that never deduped against 
Excel's default `<patternFill patternType="none"/>` and a new fill was 
appended. It now writes `patternType="none"`, exactly what Excel writes, and 
`StylesTable.putFill` finds fill 0.
   - **`CellUtil`** wrote back the border colours it had read, but 
`XSSFCellStyle.getBottomBorderColor()` etc. report `BLACK` for a side that has 
*no* colour, so every new border got `<bottom><color indexed="8"/></bottom>` 
and never equalled border 0. A side without a border has no meaningful colour, 
so the colour is now only written for sides that have a border style, and 
ignored for the others when looking for an existing style (keeps HSSF style 
reuse intact for styles that carry a colour on a `NONE` side).
   
   ### Tests
   
   - `TestXSSFCellUtil.testDefaultFillAndBorderAreReusedBug60895`: the 
reporter's scenario — after setting a data format the style has `fillId=0`, 
`borderId=0`, no fill/border was added, no border colour is present.
   - `TestXSSFCellUtil.testBorderColorIsKeptBug60895`: a real border keeps its 
colour, sides without a border get none, and the style is reused for a second 
cell.
   - `TestXSSFCellStyle.testGetFillPattern`: the `NO_FILL` step previously 
asserted that `<patternFill/>` happened to dedupe against the fixture's empty 
`<fill/>` at index 2; it now asserts it resolves to fill 0 with 
`patternType="none"`.
   
   `setFillPattern(NO_FILL)` is public behaviour: every caller now gets 
`<patternFill patternType="none"/>` instead of `<patternFill/>` — Excel's own 
form. XSSF usermodel/streaming/model and all CellUtil suites pass (the only 
local failures are the known font-metric column-width tests).
   
   🤖 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