Setting Excel Cell Colours using RGB Values

SBozhko picture SBozhko · Jul 26, 2017 · Viewed 9k times · Source

I'm trying to set Excel cells using RGB values rather than the way I do it currently as i need to set cells to a specific colour rather than a set standard colour.

This is how i currently do it:

ChartRange.Interior.Color = Microsoft.Office.Interop.Excel.XlRgbColor.rgbRed;

Is it possible to set colour in RGB values in C#?

I am working with Excel sheets that have had the colours set by RGB values in VBA.

Answer

Balagurunathan Marimuthu picture Balagurunathan Marimuthu · Jul 26, 2017

You can able to assign the System.Drawing.Color using FromArgb as below:

ChartRange.Interior.Color = System.Drawing.Color.FromArgb(255, 0, 0);