I need to resize range of conditional formatting.
Read an Excel file (.xlsm, .xlsx), modify ranges for conditional formatting, and save it as new file.
SheetConditionalFormatting sheetFormatting = sheet.getSheetConditionalFormatting(); for( int i = 0; i < sheetFormatting.getNumConditionalFormattings() ; i++ ) for( CellRangeAddress region : sheetFormatting.getConditionalFormattingAt(i).getFormattingRanges() ) if( region.getFirstRow() == 1 ) region.setLastRow( 1+data.length );
So I just get all conditional formatting objects, get range objects for them, and modify ranges by calling
The problem is that this modification is not present in result file. In fact, there are no changes in sheet.getSheetConditionalFormatting() just after the operation.
Need I ‘commit’ somehow changes to
Yes, you should add Conditional Formatting to your sheet formatting.