Java 类org.apache.poi.ss.usermodel.SheetConditionalFormatting 实例源码

项目:gw4e.project    文件:XLTest.java   
protected void formatCellStatus(Sheet sheet, Cell cell) {
    cell.setCellStyle(styles.get("status"));
    SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
    ConditionalFormattingRule ruleGreen = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "1");
    PatternFormatting fill1 = ruleGreen.createPatternFormatting();
    fill1.setFillBackgroundColor(IndexedColors.GREEN.index);
    fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
    //
    ConditionalFormattingRule ruleRed = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "0");
    PatternFormatting fill2 = ruleRed.createPatternFormatting();
    fill2.setFillBackgroundColor(IndexedColors.RED.index);
    fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
    //
    ConditionalFormattingRule ruleOrange = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "2");
    PatternFormatting fill3 = ruleOrange.createPatternFormatting();
    fill3.setFillBackgroundColor(IndexedColors.ORANGE.index);
    fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
    //
    String name = CellReference.convertNumToColString(cell.getColumnIndex());
    String location = "$" + name + "$" + cell.getRowIndex() + ":$" + name + "$" + (cell.getRowIndex() + 1);

    CellRangeAddress[] regions = { CellRangeAddress.valueOf(location) };
    ConditionalFormattingRule[] cfRules = new ConditionalFormattingRule[] { ruleGreen, ruleRed, ruleOrange };
    sheetCF.addConditionalFormatting(regions, cfRules);
}
项目:birt    文件:FilteredSheet.java   
public SheetConditionalFormatting getSheetConditionalFormatting() {
    return sheet.getSheetConditionalFormatting();
}
项目:excel-streaming-reader    文件:StreamingSheet.java   
/**
 * Not supported
 */
@Override
public SheetConditionalFormatting getSheetConditionalFormatting() {
  throw new UnsupportedOperationException();
}