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