We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Changing the chart style

We are creating charts with Aspose.Cells.Chart in our dot net code and finally inserting the image in our word document.

Everything is working fine, but the issue is chart style. Attached is our issue.

If you check the one we want is Style 3 while the one we are getting is Style 2 if you create this chart manually in MS Excel. But I am not getting how we set the same in our C# code.
I have used
chart.Style = 3; but its not working.

Other issue, can we completely remove the legend Series 2 from the chart? If yes how?


Please help…!!!


1) I have tested your scenario/ case a bit. I have used the following sample code to generate the chart and its image, it works fine. The chart does show Style3 and same is the case with output image of the chart. I am using Aspose.Cells for .NET v8.0.1 (latest version), please try it if you are not already using it.
Here is my sample code and find attached my output Excel file and rendered image:
Sample code:

Workbook workbook1 = new Workbook(FileFormatType.Xlsx);
Worksheet sheet = workbook1.Worksheets[0];

Cells cells = sheet.Cells;
cells[1, 0].PutValue(“Company A”);
cells[2, 0].PutValue(“Company B”);
cells[3, 0].PutValue(“Company C”);
cells[0, 1].PutValue(2008);
cells[0, 2].PutValue(2009);
cells[0, 3].PutValue(2010);
cells[1, 1].PutValue(10000);
cells[2, 1].PutValue(20000);
cells[3, 1].PutValue(30000);
cells[1, 2].PutValue(15000);
cells[2, 2].PutValue(25000);
cells[3, 2].PutValue(35000);
cells[1, 3].PutValue(18000);
cells[2, 3].PutValue(28000);
cells[3, 3].PutValue(38000);

int chartIndex = sheet.Charts.Add(ChartType.BarStacked, 9, 9, 21, 15);

Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add("$B$2:$D$4", false);
chart.NSeries.CategoryData = “$B$1:$D$1”;

chart.Title.Text = “Sale”;
chart.Style = 3;

2) Well, you may try the following line of code to remove the legend entry for your needs, e.g
//Delete the second entry. i.e. Series2
chart.Legend.LegendEntries[1].IsDeleted = true;

Hope, this helps a bit.

Thank you.

Thanks Amjad,
1. Did not work for me.
2. Yes, it worked, thanks.


1) If you still find the issue with latest version v8.0.1, please provide your sample code (runnable) or simple console application (you may zip it prior attaching here) with v8.0.1 and post us here, we will check your issue soon.

Thank you.

Thanks for your time Amjad.
This is how I achieved it, it did not click at the first time but its working now.

chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(147, 169, 207);



Good to know that your have figured it out now. Feel free to contact us any time if you need further help or have some queries or issue, we will be happy to assist you soon.

Thank you.