Search code examples
excelcell

change an excel cell style through C#


Is it possible to change an excel cell's style through C# if you have the indexes of the cells like:

xlWorkSheet.Cells[2,2].Style

I don't want all the row to change but only a single cell. The solutions provided before did not help.


Solution

  • For instance, if you want to chane the text color:

    xlWorkSheet.Cells[2,2].Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
    

    You can find all the properties of the cell in MSDN (such as Font)