how to add conditional formatting on cells with values greater than a specific constant value using epplus

StackOverflow https://stackoverflow.com/questions/22220551

  •  10-06-2023
  •  | 
  •  

Question

I have made an excel sheet programmatically. and now I want to add conditional formatting on a specific cell range.

The formatting type is all the cells with values greater than 0 (>0)

How to go about doing it? In excel I can do it using an inbuilt formula of Cell Values Greater Than. But how to embed it in excel using C# and epplus?

Was it helpful?

Solution

i coudnt find an exact solution to this problem. so adding my own solution that works

var cellAddress = new ExcelAddress(
                        <startingRow>, 
                        <startingcolumn>, 
                        <endingRow>, 
                        <endingColumn>);

var cf = ws.ConditionalFormatting.AddGreaterThan(cellAddress);
cf.Formula = "0";
cf.Style.Fill.BackgroundColor.Color = Color.LightGreen;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top