Created attachment 34129 [details] failing unit test patch It seems that the shiftRow method does not correctly handle shared formulas. I provide a failing unit test that higlights the problem. It seems that when updating a shared formula, the code also updates the range it is applied to. However, also the cells that are in the range are updated too, thus resulting in a double shift of the formula text and then in a not valid. I think the problem is in the class XSSFRowShifter, method updateRowFormulas. Best, Luca
Thanks for the unit test! Applied in r1761673. I can verify that the shared formula is being shifted twice. Testcase: testSharedFormulas took 0.004 sec SKIPPED: This test currently fails with org.junit.ComparisonFailure: expected:<SUM(D[2:D5])> but was:<SUM(D[3:D6])>
Created attachment 34720 [details] patch containing modification to src and test code Bug fix and unit test
The bug was due to a missing update of the CTCellFormula data structure related to the shared formula; in particular, the "ref" attribute was not updated during a row shift. The submitted patch contains the bug fix and a unit test that uses an xlsx file which is also attached.
Thanks for the patch! Applied in r1782111. Will be included in POI 3.16 beta 3.