Free Support Forum - aspose.com

Conditional Formatting - remove cell icon for specific range

Hi,

I have a question about conditional formatting,

Is there a way to turn off ranges from iconset?

(“no cell icon” for specific range)

So for example

x < 10 -> red dot

10< x < 20 -> nothing

20<x -> green dot

like this in excel:

image.png (13.2 KB)

Here is my code:

Workbook workbook = new Workbook();

        Worksheet sheet = workbook.Worksheets[0];

        ConditionalFormattingCollection cfs = sheet.ConditionalFormattings;

        int index = cfs.Add();

        FormatConditionCollection fcs = cfs[index];

        //Set the conditional format range.

        CellArea ca = new CellArea();

        ca.StartRow = 0;

        ca.EndRow = 10;

        ca.StartColumn = 0;

        ca.EndColumn = 0;

        fcs.AddArea(ca);

        //Add condition.

        int conditionIndex = fcs.AddCondition(FormatConditionType.IconSet);

        //Set the Font text color.

        FormatCondition fc = fcs[conditionIndex];

        fc.Operator = OperatorType.GreaterOrEqual;

        fc.IconSet.Type = IconSetType.TrafficLights31;

        fc.IconSet.ShowValue = true;
        fc.IconSet.Cfvos[0].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[0].Value = 10;
        fc.IconSet.Cfvos[1].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[1].Value = 30;
        fc.IconSet.Cfvos[2].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[2].Value = 40;

        fc.IconSet.Cfvos.Add(FormatConditionValueType.Number, "50");

        Aspose.Cells.Cell c = sheet.Cells["A1"];

        c.PutValue(71);

        //Save the Excel file

        workbook.Save(@"g:\out\out_iconset_cf.xlsx");

Best Regards,
Janos

@jsuta,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46265 - Remove cell icon for specific range in Conditional formatting

@jsuta,

Please make these changes to your code snippet and let us know your feedback.

        fc.IconSet.Cfvos[0].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[0].Value = 10;
        fc.IconSet.Cfvos[1].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[1].Value = 30;
        fc.IconSet.CfIcons[1].Type = IconSetType.None;
        fc.IconSet.Cfvos[2].Type = FormatConditionValueType.Number;
        fc.IconSet.Cfvos[2].Value = 40;

This is exactly what I looking for!

Thank you very much!

@jsuta,

You are welcome and thank you for the feedback.