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

   ## Tests
   
   New `BaseTestFormulaEvaluatorArrayFormulas` on the shared fixture from 
#1307, run as `TestHSSFFormulaEvaluatorArrayFormulas` and 
`TestXSSFFormulaEvaluatorArrayFormulas` (13 tests each):
   
   - multi-cell `{=A2:A4*C2:C4}`: each cell gets the element for its position, 
`evaluateAll` writes every cell's result
   - single-cell `{=SUM(A2:A4*C2:C4)}` aggregates where the plain formula gives 
`#VALUE!` (or its own row's value when inside the areas)
   - array formula over formula cells (`D2:D4` VLOOKUPs) with a plain `SUM` 
over it; a change on the Prices sheet propagates through the whole chain
   - `notifyUpdateCell` invalidates every cell of the group; without 
notification the cached results are served
   - range larger than the result → `#N/A` in the extra cells; one-column / 
one-row / scalar results are broadcast over the range
   - constant arrays (`{1;2;3}`, mixed types, combined with an area)
   - `IF` inside an array formula evaluates element-wise (the optimised-IF 
shortcut is skipped for array cells)
   - `TRANSPOSE`, `MMULT` (1x1 and 3x3 results)
   - cross-sheet areas and a defined name inside an array formula
   - replacing the array formula on the same range needs `notifySetFormula`; 
removing it leaves blank cells that `notifyUpdateCell` handles
   - write-out/read-back keeps the array formulas, their cached results, and a 
fresh evaluator agrees
   
   ## Bug fix
   
   Setting an array formula over the range of an existing one added a second 
registration instead of replacing the first (Excel replaces it when you 
re-enter the formula over its range):
   
   - **HSSF**: `SharedValueManager.addArrayRecord` appended a second 
`ArrayRecord`; `getArrayRecord` found the first, so the cells kept reporting 
the *old* formula and both records were written to the file. It now replaces a 
record with the same range.
   - **XSSF**: `XSSFSheet.setArrayFormula` added the range to `arrayFormulas` 
again. The formula itself was replaced, but after `removeArrayFormula` the 
phantom range made the blank cells still claim to be part of an array formula 
(`setBlank`/`setCellValue` threw "You cannot change part of an array"). It no 
longer records a range twice.
   
   `BaseTestSheetUpdateArrayFormulas.testSetArrayFormula_replaceOnSameRange` is 
the regression test for both formats (fails on trunk for both); the evaluator 
suite's `replacingAnArrayFormulaNeedsNotifySetFormula` also exercises it. 
`changes.xml` left for you.
   
   Locally green: the new suites, `Test*SheetUpdateArrayFormulas` (19 each), 
`hssf.record.aggregates.*`, `TestWorkbookEvaluator`, `TestFrequency`, 
`TestIndex`, `TestHSSFSheet`, `TestBugs`, `TestXSSFSheet`, 
`TestXSSFEvaluationWorkbook`, `TestXSSFXLookupFunction`.
   
   🤖 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