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.

Thu Jan 18, 2018 1:07 pm

I am trying to set the color of a data series in a chart within Spire.XLS. My code is:
Code: Select all
IChartSerie series1 = chart.Series[0];
series1.Format.Fill.FillType = ShapeFillType.SolidColor;
series1.Format.Fill.ForeColor = System.Drawing.Color.FromArgb(15, 86, 136);

IChartSerie series2 = chart.Series[1];
series2.Format.Fill.FillType = ShapeFillType.SolidColor;
series2.Format.Fill.ForeColor = System.Drawing.Color.FromArgb(0, 173, 202);

IChartSerie series3 = chart.Series[2];
series3.Format.Fill.FillType = ShapeFillType.SolidColor;
series3.Format.Fill.ForeColor = System.Drawing.Color.FromArgb(165, 208, 107);


Everything seems to run fine except that instead of the RGB values I specify in the code, the ForeColor on the series are being set to rgb(0, 128, 128), rgb(0, 102, 204), and rgb(150, 150, 150) respectively. Is there anyway to make these objects accept the specific color values I set them to?

Mike089
 
Posts: 4
Joined: Wed Jan 17, 2018 6:29 pm

Fri Jan 19, 2018 3:06 am

Hello,

Thanks for your inquiry. After an initial test with the latest version(Spire.XLS Pack Hotfix Version:7.12.144), I was unable to reproduce the issue. Please update to the version and try again. If the issue still exist, please share us with your full code, input file and out file for further investigation.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Jan 19, 2018 6:56 pm

Thank you for your response. I'm having a little issue upgrading to the latest version of Spire.XLS that you have linked. My project also has a dependency on Spire.Doc. Both Spire.Doc and Spire.XLS reference a Spire.Pdf dll, however they each specifically reference a different version of Spire.Pdf. The latest Spire.Doc (6.1.6.4040) references Spire.Pdf v3.9.597.4040 and the latest Spire.XLS (7.12.144.6040) references Spire.Pdf v3.9.593.6040. This causes a runtime exception "The assembly name resulted in the mismatch: Minor Version" to be thrown.

Mike089
 
Posts: 4
Joined: Wed Jan 17, 2018 6:29 pm

Mon Jan 22, 2018 2:09 am

Hello,

Thanks for your reply. When using two or more products in one project, please use the corresponding dlls from Spire.Office(Spire.Office Platinum (DLL Only) Version:2.16.23) to avoid the incompatibility.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 23, 2018 2:44 pm

Thank you again for your reply. I updated my project to use the .dlls in the Spire.Office project you linked to and I'm still seeing the issue. I have attached a simple Unit Test project that recreates the issue I'm seeing, along with a jpg of the output on my end.
Attachments
SpireTests.zip
(12.68 KiB) Downloaded 363 times

Mike089
 
Posts: 4
Joined: Wed Jan 17, 2018 6:29 pm

Wed Jan 24, 2018 9:09 am

Hello,

Thanks for your sharing. Please set the Excel version to 2007 or above when creating Workbook to avoid the issue.
Code: Select all
            Workbook wb = new Workbook();
            wb.Version = ExcelVersion.Version2007;


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Jan 24, 2018 3:19 pm

Confirmed that's what I was missing! Once I set the workbook version the colors render as expected. Thank you for your time and replies!

Mike089
 
Posts: 4
Joined: Wed Jan 17, 2018 6:29 pm

Thu Jan 25, 2018 1:37 am

Hello,

Thanks for your feedback. If any other query, please don't hesitate to contact us.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.XLS