Bug 60072

Summary: Sheet shiftRows doesn't trigger charts position updating
Product: POI Reporter: Lapo Cioni <lapocioni>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: normal    
Priority: P2    
Version: 3.13-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Bug Depends on: 59306    
Bug Blocks:    
Attachments: Proposed patch

Description Lapo Cioni 2016-08-31 12:12:38 UTC
Created attachment 34187 [details]
Proposed patch

Hi all, 
it seems that adding rows on a sheet (using Sheet.shiftRows) does not trigger any update in charts anchors.
Our proposal is to shift any chart anchor referring a cell above the start row of the shifted area.
I've attached a patch that includes a new method in XSSFSheet, called from within the shiftRows method.
Comment 1 Javen O'Neal 2016-08-31 15:41:03 UTC
Thanks for the patch! I'll review it and apply it once 3.15 is released and the trunk is unfrozen.

Does your patch also update chart data series address ranges? See bug 59306. It would be nice to have these two fixed at the same time.
Comment 2 Lapo Cioni 2016-09-01 16:50:45 UTC
(In reply to Javen O'Neal from comment #1)
> Thanks for the patch! I'll review it and apply it once 3.15 is released and
> the trunk is unfrozen.
> 
> Does your patch also update chart data series address ranges? See bug 59306.
> It would be nice to have these two fixed at the same time.

Unfortunately no.
I've only made some failed attempts to solve the issue related to bug 59306.
Comment 3 Javen O'Neal 2016-09-10 05:17:32 UTC
Could you move the drawing (chart, picture, object, etc) shifting into the XSSFRowShifter or RowShifter class?

Would you be willing to write a unit test for this class to prevent regressions on this feature in future releases? There is a class called TestXSSFSheetShiftRows or BaseTestSheetShiftRows that would be a good place for this test. This also proves to others that the behavior works as described.

Thanks!
Comment 4 Javen O'Neal 2016-09-10 05:22:13 UTC
You can use test-data/spreadsheet/WithChart.xlsx and WithDrawing.xlsx for unit tests or make your own test spreadsheet (or even better, write a unit test starting with a new XSSFWorkbook(), add the chart and/or drawing to the workbook, shift the rows, and verify that the chart and drawing were shifted the correct number of rows.

https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/
Comment 5 Dominik Stadler 2021-02-17 07:16:50 UTC
Bug #59306 sounds similar or at least closely related.