如何使用Apache POI在Excel中填充特定测试的背景颜色?

时间:2015-04-03 12:57:45

标签: java excel excel-formula apache-poi

我想填充其值为"失败"的单元格的背景颜色,我尝试了以下代码,但它不起作用。

 ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("COUNTIF($J$2:$J$11,J2)=Fail");
    PatternFormatting fill2 = rule2.createPatternFormatting();
    fill2.setFillBackgroundColor(IndexedColors.RED.index);
    fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
    CellRangeAddress[] regions2 = { CellRangeAddress.valueOf("J2:J10") };
    sheetCF.addConditionalFormatting(regions2, rule2);

createconditionalformatting的公式是什么?

0 个答案:

没有答案