How do you get ClosedXML to use conditional formatting with formulas?

According to the documentation, you can add conditional formatting to a cell using the syntax:

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

So, I tried this:

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

However, when I try to do this, load the spreadsheet into Excel and look at the conditional formatting for the cell; it seems to have changed it to the simple type of cell value equals rather than the type of formula. Therefore, I see the following:

enter image description here

but I want to see the following:

enter image description here

What am I missing ??

+4
source share
2 answers

Google . WhenIsTrue(), !

, , - ( , -, Google " closedxml" ), .

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

:

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

Source: https://habr.com/ru/post/1607432/


All Articles