Problem with getting Excel cell background colors in C#

前端 未结 2 964
情书的邮戳
情书的邮戳 2020-12-19 08:47

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];           


        
2条回答
  •  生来不讨喜
    2020-12-19 08:58

    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)

提交回复
热议问题