Search code examples
silverlightexcelcolorscomautomationfactory

How to Change Color of a cell in excel from Silverlight using Com AutomationFactory


Hi Im using AutomationFactory from silverlight to create and manipulate Exel worksheet. And I want to change Color of a cell. If I understand correctly I must change this property

cell.Interior.Color = 

However I want to change it to MyObject.Color (whitch is of tzpe Color) MSDN Says i should use RGB function to assign cell.Interior.Color But there is no RGB function in silverlight!? How to change Color to something cell.Interior.Color will understand?


Solution

  • I made RGB function..

    internal static int RGB(Color color)
            {
                string hexaString=color.B.ToString("X2") + color.G.ToString("X2") + color.R.ToString("X2");
                int rgb = int.Parse(hexaString, System.Globalization.NumberStyles.HexNumber);
                return rgb;
            }