title: Conditional Formatting in Excel with C#
body: <p>I need to apply a color to a cell's text if the value is not same as a value in another column. What would be the best approach for it ? The way I can think of is quite expensive.</p>
  
  <pre><code> for (int i = 0; i &lt; ColumnARange.Cells.Count; i++)
                      {
                          if (ColumnARange.Cells[i, 1] != ColumnBRange.Cells[i, 1])
                          {
                              Range currCell = ColumnBRange.Cells[i, 1];
                              currCell.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
                          }
                      }
  </code></pre>
  
  <p>Tried conditional formatting as below, but in vain.</p>
  
  <pre><code>FormatCondition cond = ColumnBRange.FormatConditions.Add(XlFormatConditionType.xlCellValue, XlFormatConditionOperator.xlNotEqual, ColumnARange);
                  cond.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
  </code></pre>
  
  <p>I am using VSTO,C#</p>