Link to home
Start Free TrialLog in
Avatar of Skale
Skale

asked on

Conditional formatting issue in ClosedXML

In my tool i have code like below to conditional formatting the cells as icons

if they are greater than 0 they will get green check icon, if cell value = 0 they will turn to yellow exclamation symbol and if they are below zero they should represent with red cancel icon.

But the problem is it doesnt effect the greaterthen value so my conditional formatting not works properly.

User generated image


Any help would be grateful.

Thanks.

        private void ConditionalFormatStatus(IXLWorksheet worksheet)
        {
            IXLCell first_cell = worksheet.Cell(2, 6);
            IXLCell last_cell = worksheet.Cell(worksheet.LastRowUsed().RowNumber(), 6);

            IXLRange range = worksheet.Range(first_cell.Address, last_cell.Address);

            range.AddConditionalFormat().IconSet(XLIconSetStyle.ThreeSymbols, false, true)
                .AddValue(XLCFIconSetOperator.EqualOrGreaterThan, 0, XLCFContentType.Number)
                .AddValue(XLCFIconSetOperator.GreaterThan, 0, XLCFContentType.Number);
            //.AddValue(XLCFIconSetOperator., 3, XLCFContentType.Number);
        }

Open in new window

Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

The problem is that you have conditions overlap. EqualOrGreaterThan should be replaced with Equal if available.
Avatar of Skale
Skale

ASKER

Hi Eduard,

There's no Equal property :(
ASKER CERTIFIED SOLUTION
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Skale

ASKER

I added for all of them EqualorGreaterThan and it works. And as you said i added additional one.