你如何让ClosedXML使用公式的条件格式?

时间:2015-09-15 10:21:24

标签: c# .net conditional-formatting closedxml

根据documentation,您可以使用以下语法向单元格添加条件格式:

.AddConditionalFormat().WhenEquals("=B1")

所以我尝试了这个:

cell.AddConditionalFormat().WhenEquals("=F5=0")
    .Fill.SetBackgroundColor(XLColor.FromHtml("#f00"));

但是,每当我尝试这个时,将电子表格加载到Excel中,并查看单元格的条件格式,它似乎已将其更改为简单的“单元格值等于”类型,而不是公式类型。所以我看到了这个:

enter image description here

但我想看到的是:

enter image description here

我错过了什么!?

2 个答案:

答案 0 :(得分:11)

在Google无数次挖掘数小时之后,我放弃了并回归基础。我最终注意到一个名为WhenIsTrue()的方法,它接受一个公式!

所以,如果有其他人到这里寻找这个(这个问题似乎是谷歌第二个最佳排名答案,条件格式化closedxml'),这就是答案。

cell.AddConditionalFormat().WhenIsTrue("=F5=0")
    .Fill.SetBackgroundColor(XLColor.FromHtml("#f00"));

答案 1 :(得分:0)

我能够像这样工作:

 <div ng-repeat="tweet in tweets" class="post-body clearfix">
   <p ng-bind-html="tweet.text"></p>
</div>
相关问题