Changing an Excel cell's backcolor using hex results in Excel displaying completely different color in the spreadsheet

后端 未结 7 1891
灰色年华
灰色年华 2021-02-07 13:27

So I am setting an Excel cell\'s Interior Color to a certain value, like below:

worksheet.Cells[1, 1].Interior.Color = 0xF1DCDB;

However, when

7条回答
  •  既然无缘
    2021-02-07 13:46

    Just wanted to post my code, too. Since there was no copy&paste solution for me. Based on Sandesh 's code:

    private void ColorMe(Color thisColor){
    rng = xlApp.ActiveCell;
    Color mycolour = ColorTranslator.FromHtml("#" + thisColor.Name.Substring(2, 6));
    rng.Interior.Color = Color.FromArgb(mycolour.R, mycolour.G, mycolour.B);
    }
    

提交回复
热议问题