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

   Fixes #1416.
   
   Adds `CellCopyPolicy.isAdjustFormulaReferences()` / 
`setAdjustFormulaReferences(boolean)` / 
`Builder.adjustFormulaReferences(boolean)`. It defaults to `false`, so existing 
callers are unaffected. The copy constructor and `createBuilder()` carry it 
over.
   
   When it is set, `CellUtil.copyCell` moves a copied formula's relative 
references by the row and column offset from the source cell to the destination 
cell, as Excel's copy and paste does. It works through 
`Workbook.createEvaluationWorkbook()`, so it covers HSSF, XSSF and SXSSF 
destinations.
   - Absolute references and the absolute parts of mixed references stay put. 
3D references keep their sheet.
   - It uses a row-copy and a column-copy `FormulaShifter` built with the 
destination's `SpreadsheetVersion`, so references pushed past the sheet edge 
become `#REF!`.
   - It parses against the destination workbook. If the formula can't be parsed 
there, it is copied unchanged, the same as with the setting off.
   - `XSSFRow.copyRowFrom` and `HSSFRow.copyRowFrom` already shift the whole 
row after copying. They turn the setting off for their per-cell copies, so 
formulas are not shifted twice.
   
   Left out: the issue's optional follow-ups (a "formulas only" copy and 
`SXSSFRow.copyRowFrom`).
   
   Tests: shared tests in `BaseTestCellUtilCopy` (HSSF, XSSF and SXSSF), plus 
no-double-shift tests in `TestHSSFRow` and `TestXSSFRow`.
   
   🤖 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