private void SetRule(XSSFSheet sheet)
{
var conditionFormatting = sheet.SheetConditionalFormatting;
AddConditionalFormatting(conditionFormatting, ECUCommon._cGWMList[0], NPOI.HSSF.Util.HSSFColor.Green.Index, 7);
AddConditionalFormatting(conditionFormatting, ECUCommon._cGWMList[1], NPOI.HSSF.Util.HSSFColor.Red.Index, 7);
AddConditionalFormatting(conditionFormatting, ECUCommon._cGWMList[2], NPOI.HSSF.Util.HSSFColor.Yellow.Index, 7);
AddConditionalFormatting(conditionFormatting, ECUCommon._curStatus[0], NPOI.HSSF.Util.HSSFColor.Red.Index, 9);
AddConditionalFormatting(conditionFormatting, ECUCommon._curStatus[1], NPOI.HSSF.Util.HSSFColor.Green.Index, 9);
}
private void AddConditionalFormatting(ISheetConditionalFormatting conditionFormatting, string v, short fillColor, int colindex)
{
var rule = conditionFormatting.CreateConditionalFormattingRule(NPOI.SS.UserModel.ComparisonOperator.Equal, $"\"{v}\"");
var patternFormat = rule.CreatePatternFormatting();
patternFormat.FillBackgroundColor = fillColor;
patternFormat.FillPattern = FillPattern.SolidForeground;
var regions = new CellRangeAddress[] { new CellRangeAddress(1, _survey.surveydetail_info.Count, colindex, colindex) };
int nResult = conditionFormatting.AddConditionalFormatting(regions, rule);
}