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

时间:2014-03-06 09:44:11

标签: c# excel epplus

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

格式化类型是values greater than 0 (>0)

的所有单元格

如何去做? 在excel中,我可以使用Cell Values Greater Than的内置公式来完成它。但是如何使用C#和epplus将它嵌入excel?

1 个答案:

答案 0 :(得分: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;
相关问题