While there is a method that given a ConditionalFormatting object returns the array of CellRangeAddress is applied to, there is no public method to set a new array of CellRangeAddress. We suggest to add a method to the XSSFSheetConditionalFormatting that sets the a new formatting range i.e. public void setFormattingRanges(CellRangeAddress[] ranges) { ... }
I just created the pull request #42 on on GitHub [1] The pr includes the new method and and adds a simple unit test to the TestXSSFConditionalFormatting class. This very simple contribution could be reused when implementing conditional formatting copy as see in bug 58348. Best, Luca [1] https://github.com/apache/poi/pull/42
Two things that'd be great: * Any chance you could write a junit unit test for this change, so we can ensure it works, and stays working? * Any chance you could be inspired by the logic in CFRecordsAggregate.updateFormulasAfterCellShift to write an equivalent HSSF set method?
Thank you Nick for your comment. I implemented the method also for HSSF and pulled up the method to the interface. The pull requested already contained an unit test. I added two more unit tests and put them in the base test classes, so to exercise both HSFF and XSSF. Best, Luca
The issue has been solved in r1768588 Thank you. Luca