[]
        
(Showing Draft Content)

设置条件格式

请参考以下示例代码,通过设置单元格颜色,在数据透视表报表的最后一行中设置条件格式。

// set condional format to the last row
int rowCount = pivottable.getDataBodyRange().getRowCount();
IAboveAverage averageCondition = pivottable.getDataBodyRange().getRows().get(rowCount - 1).getFormatConditions()
        .addAboveAverage();
averageCondition.setAboveBelow(AboveBelow.AboveAverage);
averageCondition.getInterior().setColor(Color.GetPink());

// save to an excel file
workbook.save("PTConditionalFormat.xlsx");

注意: 如果数据透视表以任何方式更改,则应用于数据透视表的条件格式将丢失。