I am trying to set up conditional formatting in an Excel file using the DocumentFormat.OpenXml library. Specifically, I want to use a red X and a green checkmark from the ThreeSymbols icon set. However, this icon set also includes a yellow exclamation mark, which I do not want to use. The issue is that the library does not allow the creation of a custom icon set to exclude the yellow exclamation mark.
To Reproduce
Create a new Excel file.
Apply conditional formatting using the ThreeSymbols icon set.
Attempt to customize the icon set to exclude the yellow exclamation mark.
Expected behavior
• If the value is equal to 0, no icon should be displayed.
• If the value is equal to 1, a green checkmark icon should be displayed.
• If the value is greater than 1, a red X icon should be displayed.
Additional Information: I also tried using the IconFilter class, but it did not work as expected.
var cColumn = new ConditionalFormatting();
worksheetPart.Worksheet.InsertAfter(cColumn, worksheetPart.Worksheet.Descendants<SheetData>().LastOrDefault());
cColumn.SequenceOfReferences = new ListValue<StringValue> { InnerText = "C:C" };
var cfRuleCColumn = cColumn.AppendChild(new ConditionalFormattingRule());
cfRuleCColumn.Type = ConditionalFormatValues.IconSet;
cfRuleCColumn.Priority = 1;
var iconSet = new IconSet()
{
ShowValue = false,
Reverse = true,
};
var iconSetCColumn = cfRuleCColumn.AppendChild(iconSet);
iconSetCColumn.AppendChild(new ConditionalFormatValueObject
{
Type = ConditionalFormatValueObjectValues.Number,
Val = "0",
GreaterThanOrEqual = BooleanValue.FromBoolean(false),
});
iconSetCColumn.AppendChild(new ConditionalFormatValueObject
{
Type = ConditionalFormatValueObjectValues.Number,
Val = "1",
GreaterThanOrEqual = BooleanValue.FromBoolean(true),
});
iconSetCColumn.AppendChild(new ConditionalFormatValueObject
{
Type = ConditionalFormatValueObjectValues.Number,
Val = "2",
GreaterThanOrEqual = BooleanValue.FromBoolean(true),
});
iconSetCColumn.AppendChild(new ConditionalFormatValueObject
{
Type = ConditionalFormatValueObjectValues.Number,
Val = "3",
GreaterThanOrEqual = BooleanValue.FromBoolean(true),
});