Search code examples
c#excelcolorssystem.drawing

How to assign System.Drawing.Color to Microsoft.Office.Interop.Excel.ColorFormat


Sample code as follow,

Chart.SerialsCollection(1).Point(1).Format.Fill.ForeColor = System.Drawing.Color.Red;

Return an error. Cannot implicitly convert type, one is a Struct, the other is ColorFormat.

ForeColor.RGB is Int type, I can only get 3 ints from Color.Red.R, Color.Red.G and Color.Red.B. How to assign the color I want to ForeColor property?


Solution

  • Try RGB property ForeColor.RGB

    E.g.

    Chart.SerialsCollection(1).Point(1).Format.Fill.ForeColor.RGB = System.Drawing.Color.Red.ToArgb();