[简单]poi Conditional Format

       
[简单]poi Conditional Format_第1张图片
      Excel的条件格式可以使用poi的 Conditional Format实现,代码:

     

//>=60
		SheetConditionalFormatting condFmt = sheet.getSheetConditionalFormatting();
                ConditionalFormattingRule condRule = condFmt.createConditionalFormattingRule(ComparisonOperator.GE, "60");
		FontFormatting ruleFmt = condRule.createFontFormatting();
		ruleFmt.setFontColorIndex(IndexedColors.RED.getIndex());
		PatternFormatting fillFmt= condRule.createPatternFormatting();
		fillFmt.setFillBackgroundColor(IndexedColors.LEMON_CHIFFON.getIndex());
	
		int rowNum=sheet.getLastRowNum();
		CellRangeAddress[] cellRange =getSingleCellRangeAddress(4, "%s3:%s%s", rowNum);
		condFmt.addConditionalFormatting(cellRange, condRule);

    其他的请自行搜索,结果和下图类似:

    
[简单]poi Conditional Format_第2张图片
     全文完。

 

 

你可能感兴趣的:(Condition)