How to change Series color from a pivot Chart

sheet3.Charts[index].NSeries[0].Area.ForegroundColor = Color.Blue;
is not working rather throwing error.it works in a normal chart that where i can get all the series and change there colors programmatically but doesnt work in pivot chart. The Nseries is returning count of 0 but the plot is showing when downloaded and excel using it defaults series color.


Hi,

Please download and try the latest fix/version: Aspose.Cells for .NET (Latest Version). It works fine as I have tested with it. I used a template file (attached) which already has a pivot table and pivot chart. I refresh the pivot table and its data accordingly, get the chart object, now change the foreground color of the first series and then re-save the file (attached), it works fine.

Please see the sample code for your reference:

Sample code:

Workbook workbook = new Workbook(“e:\test2\my_pvtchart.xls”);

PivotTable pvt = workbook.Worksheets[0].PivotTables[0];

pvt.RefreshData();

pvt.CalculateData();

Chart chart = workbook.Worksheets[1].Charts[0];

chart.RefreshPivotData();

chart.NSeries[0].Area.ForegroundColor = Color.Yellow;

workbook.Save(“e:\test2\outputmypvtchart1.xls”);

Thank you.