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.
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.
(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.
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!
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/
Bug #59306 sounds similar or at least closely related.