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.
读取Excel文件(.xlsm,.xlsx),修改条件格式的范围,并将其另存为新文件。
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 CellRangeAddress.setLastRow()
.
所以我只获取所有条件格式化对象,获取它们的范围对象,并通过调用CellRangeAddress.setLastRow()来修改范围。
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.
问题是结果文件中不存在此修改。事实上,在操作之后,sheet.getSheetConditionalFormatting()没有任何变化。
Need I 'commit' somehow changes to ConditionalFormatting
?
需要我'提交'以某种方式更改ConditionalFormatting?
1 个解决方案
#1
2
Yes, you should add Conditional Formatting to your sheet formatting.
是的,您应该为工作表格式添加条件格式。
sheetFormatting.addConditionalFormatting(newRange,arrayOfRules);
#1
2
Yes, you should add Conditional Formatting to your sheet formatting.
是的,您应该为工作表格式添加条件格式。
sheetFormatting.addConditionalFormatting(newRange,arrayOfRules);