Excel C# 中的条件格式规则 - 检查不同列中的单元格是否具有特定值

Excel Conditional Format Rule in C# - Check whether cells in a different column for a certain value

我想要 Y 列中的条件格式规则,它检查同一行的 A 列是否具有 No 作为值。
但是代码line 1有错误,具体是什么我也不知道

应该是这样的结果:

这是我的代码:

FormatCondition format = (FormatCondition)ws.Cells.Range[Y:Y].FormatConditions.Add(cell["A1"], XlFormatConditionOperator.xlEqual, "No");
format.Interior.Color = LIGHT_GREY;
format.Font.Color = GREY;

(Note: GREY and LIGHT_GREY are readonly variables which work in other code snippets)

您似乎把 Add 的参数搞错了。我相信它应该是以下内容,但我无法对其进行测试..

Add(XlFormatConditionType.xlExpression, Formula1: "=$A1=\"No\"");