Show / Hide Table of Contents

Conditional Formatting Icon Set

Output: ConditionalFormattingIconSet.xlsx

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

    worksheet["A1"].Value = "Default Three Arrows";
    worksheet.GetRange("B1:F1").SetValue(new int[] {1, 2, 3, 4, 5});
    worksheet.ConditionalFormattings.AddIconSet("B1:F1", IconSetType.ThreeArrows);

    worksheet["A2"].Value = "Custom ThreeTrafficLights2 Minimum:25% Maximum:75%";
    worksheet.GetRange("B2:F2").SetValue(new int[] {1, 2, 3, 4, 5});
    var rule = worksheet.ConditionalFormattings.AddIconSet("B2:F2", IconSetType.ThreeTrafficLights2);
    rule.IconSet.Conditions[1].Type = ConditionValueType.Percent;
    rule.IconSet.Conditions[1].Value = 50;
    rule.IconSet.Conditions[2].Type = ConditionValueType.Percent;
    rule.IconSet.Conditions[2].Value = 75;

    worksheet["A3"].Value = "Default Five Rating";
    worksheet.GetRange("B3:F3").SetValue(new int[] {1, 2, 3, 4, 5});
    worksheet.ConditionalFormattings.AddIconSet("B3:F3", IconSetType.FiveRating);
    workbook.SaveAs("ConditionalFormattingIconSet.xlsx");
}
Back to top Generated by DocFX