You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/10/16 18:37:21 UTC
[PR] CellCopyPolicy: opt-in adjustment of relative formula references [poi]
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] CellCopyPolicy: opt-in adjustment of relative formula references [poi]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1418:
URL: https://github.com/apache/poi/pull/1418
--
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org