I am trying to get background color of some cells in an Excel sheet in C#. I am using follwoing code for it:
Excel.Range r = (Excel.Range)m_objRange[i, j];
try this:
System.Color col = System.Drawing.ColorTranslator.FromOle((int) r.Interior.Color);
string htmlCol = System.Drawing.ColorTranslator.ToHtml(col);
(warning, I didn't test this)
This work for me:
int colorNumber = System.Convert.ToInt32(((Range) worksheet.Cells[rowNumber,columnNumber]).Interior.Color);
Color color = System.Drawing.ColorTranslator.FromOle(colorNumber);