Search code examples
c#exceloffice-interop

Microsoft.Office.Interop.Excel reading false color?


tmp.Color = xlRange.Cells[i, j].Interior.Color.ToString();

I read the Cellcolor of an excel document like this, but I get not the color I expect: 16777215 for aquamarine for example but it´s not the value for aquamarine, it´s the value for yellow. Am I reading the cellcolor not right?


Solution

  • I have just found solution for you, And hope this will work for you.

    int colorNumber = System.Convert.ToInt32(((Range) worksheet.Cells[rowNumber,columnNumber]).Interior.Color);
    Color color = System.Drawing.ColorTranslator.FromOle(colorNumber);
    

    Refrence link : https://stackoverflow.com/a/1867695/6923146