Cell color changing in Excel using C#

Suryakavitha picture Suryakavitha · Mar 16, 2010 · Viewed 153k times · Source

I am using a Windows application for exporting a data table to Excel. It's working. Now I want to give some color for particular text in the cell. How shall I do this?

Answer

Aseem Gautam picture Aseem Gautam · Mar 16, 2010

For text:

[RangeObject].Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

For cell background

[RangeObject].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);