如何使用epplus在值大于特定常量值的单元格上添加条件格式

Par*_*rma 2 c# excel epplus

我已经以编程方式制作了一张excel表.现在我想在特定的单元格范围上添加条件格式.

格式化类型是所有单元格 values greater than 0 (>0)

怎么去做呢?在excel中,我可以使用内置公式来实现Cell Values Greater Than.但是如何使用C#和epplus将它嵌入excel?

Par*_*rma 9

我找到了解决这个问题的确切方法.所以添加我自己的解决方案

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

var cf = ws.ConditionalFormatting.AddGreaterThan(cellAddress);
cf.Formula = "0";
cf.Style.Fill.BackgroundColor.Color = Color.LightGreen;
Run Code Online (Sandbox Code Playgroud)

  • 你还必须在ws.ConditionalFormatting行中更改formulla的类型 (2认同)