Bug 59983

Summary: [PATCH] Wrong update of shared formulas after shiftRow
Product: POI Reporter: Luca Martini <lucamartini>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: chiaramarcheschi
Priority: P2 Keywords: PatchAvailable
Version: 3.16-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: failing unit test patch
patch containing modification to src and test code

Description Luca Martini 2016-08-11 15:26:38 UTC
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
Comment 1 Javen O'Neal 2016-09-21 05:23:07 UTC
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])>
Comment 2 Chiara Marcheschi 2017-02-06 14:42:47 UTC
Created attachment 34720 [details]
patch containing modification to src and test code

Bug fix and unit test
Comment 3 Chiara Marcheschi 2017-02-06 14:54:10 UTC
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.
Comment 4 Javen O'Neal 2017-02-08 07:21:18 UTC
Thanks for the patch! Applied in r1782111.

Will be included in POI 3.16 beta 3.