NPOI:如何在条件格式中使用自定义XSSFColor?

时间:2015-02-01 13:14:05

标签: c# excel conditional-formatting npoi xssf

我有什么:

var sheetCf = sheet.SheetConditionalFormatting;
var rule = sheetCf.CreateConditionalFormattingRule("A2>0");
var fill = rule.CreatePatternFormatting();

fill.FillBackgroundColor = IndexedColors.Red.Index;
fill.FillPattern = (short)FillPattern.SolidForeground;

如何为背景设置自定义颜色?

1 个答案:

答案 0 :(得分:0)

你在找这个吗?

XSSFCellStyle myCellStyle = (XSSFCellStyle)workbook.CreateCellStyle();
myCellStyle.FillBackgroundColor = IndexedColors.LightYellow.Index;
myCellStyle.FillPattern = FillPattern.NoFill;
myCellStyle.FillForegroundColor = IndexedColors.LightTurquoise.Index;