c#应用程序excel vsto条件格式

c#应用程序excel vsto条件格式,c#,excel,vsto,C#,Excel,Vsto,我有一个VSTO c#应用程序,我正在尝试应用条件格式,因此当第V列中的值设置为“否”时,会使整行变为灰色。headercount变量是我的最后一列编号 Microsoft.Office.Interop.Excel.FormatCondition format7 = (Microsoft.Office.Interop.Excel.FormatCondition)(uiWorksheet.get_Range("B7:Z" + headercount, Type.Missing).F

我有一个VSTO c#应用程序,我正在尝试应用条件格式,因此当第V列中的值设置为“否”时,会使整行变为灰色。headercount变量是我的最后一列编号

      Microsoft.Office.Interop.Excel.FormatCondition format7 = (Microsoft.Office.Interop.Excel.FormatCondition)(uiWorksheet.get_Range("B7:Z" + headercount,
  Type.Missing).FormatConditions.Add(Microsoft.Office.Interop.Excel.XlFormatConditionType.xlExpression, Microsoft.Office.Interop.Excel.XlFormatConditionOperator.xlEqual,
  "V=No", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing));
        format7.Interior.Color = true;

我尝试了下面的方法,但不起作用-有什么想法吗?

我可以使用Excel的
间接
功能,通过
应用程序触发的条件格式设置。SheetChange
事件来实现这一点。请注意,公式的内部引号需要转义

Microsoft.Office.Interop.Excel.FormatCondition format7 = (Microsoft.Office.Interop.Excel.FormatCondition)(uiWorksheet.get_Range("B7:Z" + headercount,
Type.Missing).FormatConditions.Add(Microsoft.Office.Interop.Excel.XlFormatConditionType.xlExpression, Microsoft.Office.Interop.Excel.XlFormatConditionOperator.xlEqual,
"=INDIRECT(\"V\"&ROW())=\"No\"", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing));

format7.Interior.Color = System.Drawing.Color.Gray;