Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Sat Jan 12, 2019 7:35 pm

Hi!
i can set only one color using RGB and ChangePaletteColor function. but when I set several colors and use ChangePaletteColor everything goes wrong((

How can I set more colors using RGB

RomaA8
 
Posts: 7
Joined: Fri Feb 17, 2017 11:27 am

Mon Jan 14, 2019 5:42 am

Hi,

Thanks for your inquiry.
Where do you want to set the color? Here is sample code for your kind reference:
Code: Select all
           //use the method Color.FromArgb which is in System.Drawing.color
           sheet.Range["B1"].Style.Color = Color.FromArgb(0, 10, 10);

If I misunderstand your meaning, please share us more detailed information.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Tue Jan 15, 2019 2:13 pm

unfortunately it does not work

Here are the colors I want to set
Code: Select all
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(28, 58, 112);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(204, 192, 218);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(252, 213, 180);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(141, 180, 226);


but, I get completely different

Code: Select all
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(0, 51, 102);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(192, 192, 192);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(255, 204, 153);
            worksheet.Range[range].Style.Color = System.Drawing.Color.FromArgb(153, 204, 255);

RomaA8
 
Posts: 7
Joined: Fri Feb 17, 2017 11:27 am

Wed Jan 16, 2019 7:41 am

Hi,

Thanks for your information.
The issue is because the default version(Excel 97-2003) is not same as the saved version. You need to specify the correct Excel version like below.
Code: Select all
            Workbook workbook = new Workbook();
            //specify the version
            workbook.Version = ExcelVersion.Version2013;
            sheet.Range["B3"].Style.Color = System.Drawing.Color.FromArgb(204, 192, 218);
            //save as Excel2013 file
            workbook.SaveToFile("16137.xlsx",ExcelVersion.Version2013);


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Wed Jan 16, 2019 10:58 am

Hi!

sorry, but it does not work for

Code: Select all
Spire.Xls.FileFormat.Version2013

or
Code: Select all
Spire.Xls.ExcelVersion.Version2013

RomaA8
 
Posts: 7
Joined: Fri Feb 17, 2017 11:27 am

Thu Jan 17, 2019 5:49 am

Hi,

Sorry to hear that.
Kindly note you need to firstly specify the version as below:
Code: Select all
            //specify the version
            workbook.Version = ExcelVersion.Version2013;

Besides, here is a demo, please run it on your side.
http://www.e-iceblue.com/downloads/demo/16137.zip
And I attached the screenshot of showing the result on my side. If you still have the issue, please tell us following information.
1. The OS and Region information, e.g. Win7 64bit, China/Chinese.
2. The Excel Version you used to open the result.

Sincerely,
Betsy
E-iceblue support team
Attachments
customColor.png
customColor.png (24.82 KiB) Viewed 388 times
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Thu Jan 17, 2019 10:24 am

Hi!
Now it worked right!
thank you so much!!!

RomaA8
 
Posts: 7
Joined: Fri Feb 17, 2017 11:27 am

Fri Jan 18, 2019 1:52 am

Hi,

Glad to hear that.
Any question, please feel free to contact us. :)

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS