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

   Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=69463
   
   ### Problem
   
   In the reporter's workbook the cell that turns black while being edited (B2) 
has **no fill** (`fillId="0"`); the neighbouring cell with a solid theme fill 
(A2) is fine. `CellUtil.setCellStyleProperties(cell, {LOCKED: false})` rebuilds 
the cell's style from its properties, and for a no-fill style that produced
   
   ```xml
   <patternFill><fgColor indexed="64"/><bgColor indexed="64"/></patternFill>
   ```
   
   XSSF reports a *missing* fill colour as the automatic index 64, and 
`setFormatProperties` wrote those back as explicit indexed colours into a fill 
that has no pattern type — a shape Excel never writes, and which it renders as 
a black cell in edit mode. The reporter's fork (dropping the two indexed-colour 
setters) confirms that: their output has no colours in the fill and behaves.
   
   ### Fix
   
   An automatic fill colour is what a freshly created style already has, so the 
indexed setters are skipped for `IndexedColors.AUTOMATIC`. Colours that are 
actually present in the source fill (indexed, RGB or theme, including Excel's 
own `<bgColor indexed="64"/>` on solid fills) are still applied through the 
`Color` objects, so those fills round-trip unchanged.
   
   HSSF is unaffected: its `getFill*ColorColor()` returns a non-null 
`AUTOMATIC` colour for index 64, so its `Color` path re-applies the same values 
as before.
   
   ### Tests
   
   - `testNoFillCellStaysWithoutFillColorsBug69463`: the reporter's case — a 
no-fill cell keeps a fill with no `fgColor`/`bgColor` elements, and its other 
properties.
   - `testSolidThemeFillIsKeptBug69463`: the A2 case — a solid fill with a 
theme colour and `bgColor indexed="64"` is preserved.
   - Four bug-66052 tests asserted that a *background* colour that was never 
set comes back as `AUTOMATIC`; that was recording the fabricated `<bgColor 
indexed="64"/>`, so those assertions are now `assertNull`.
   
   🤖 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