• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support

Conditional Formatting Specific Text

Output: ConditionalFormattingSpecificText.xlsx

public void Run()
{
    var workbook = new Workbook();
    var worksheet = workbook.Worksheets[0];
    worksheet.Columns[0].WidthCharacters = 40;
    worksheet.Columns.SetWidthCharacters("B", "F", 5);

    worksheet.GetRange("B1:E1").SetValue(new[] {"ABC", "BCD", "DEF", "EFG"});
    worksheet.GetRange("B2:E2").SetValue(new[] {"ABC", "BCD", "DEF", "EFG"});

    worksheet["A1"].Value = "Text does not contain BC";
    var ruleB1 = worksheet.ConditionalFormattings.AddSpecificText("B1:E1", SpecificTextFormattingRuleType.NotContaining, "BC");
    ruleB1.Fill = CellFill.CreateSolidFill(SpreadsheetColor.Accent1);

    worksheet["A2"].Value = "Text ending with FG";
    var ruleB2 = worksheet.ConditionalFormattings.AddSpecificText("B2:E2", SpecificTextFormattingRuleType.EndingWith, "FG");
    ruleB2.Fill = CellFill.CreateSolidFill(SpreadsheetColor.Accent1);

    workbook.SaveAs("ConditionalFormattingSpecificText.xlsx");
}
  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX