Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Nov 05, 2010 5:55 am

When setting the style.color of a range on a sheet it appears that no matter what Drawing.color.FromArgb values I set it to it will only set the colors to web colors (the full spectrum is not available like it is from within Excel). Am I doing something wrong?

Thanks.

tmayne77
 
Posts: 9
Joined: Tue Nov 02, 2010 1:52 pm

Mon Nov 08, 2010 3:06 am

Hello,

Thank you for your inquiry.
Could you elaborate and give us more details, we will check it soon.

Best Regards.
User avatar

Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Mon Nov 08, 2010 4:55 am

the line of code I'm trying to use is the following:
coverSheet.Range(2, 5, 2, 9).Style.Color = Drawing.Color.FromArgb(55, 96, 145)

but the actual output in the excel file gives me the color with the following RGB value:
R:51 G:51 B:153

What is changing the colors? How do I get the {55,96,145} values to stick?

I referenced "web colors" in my post because in Photoshop's colorpicker if I enter my intended RGB values and then check the "only Web colors" checkbox it gives me something very close to the {51,51,153} color value.

thank you for your time.

tmayne77
 
Posts: 9
Joined: Tue Nov 02, 2010 1:52 pm

Mon Nov 08, 2010 7:05 am

Hello,

Thank you for your additional information.

Please try to use following source code to set excel pallette color, then you color can not be changed.
Code: Select all
workbook.ChangePaletteColor(System.Drawing.Color.FromArgb(55, 96, 145), 9);


Please let me know if you have any questions and concerns.

Best Regards.
User avatar

Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Mon Nov 08, 2010 3:31 pm

This appears to have worked, although I don't understand what it does. Do I have to do this for every color I want to use in my workbook?

tmayne77
 
Posts: 9
Joined: Tue Nov 02, 2010 1:52 pm

Wed Nov 10, 2010 8:57 am

Hello,

Thank you for your inquiry.
Excel's color palette contains 56 colors,so if you specific a color ,then the color will be replace similar pallette color.
Please let me know if you have any questions and concerns.

Best Regards.
User avatar

Jason.Tan
 
Posts: 30
Joined: Tue May 25, 2010 7:17 am

Return to Spire.XLS