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

Free Support Forum - aspose.com

Create a Chart with a Dynamic Data Range

I have a presentation template with very specific styling rules/guidelines. One of those rules is that the number of bars in a chart can change dynamically.

The template currently sets a static data range of “Sheet1!$A$1:$B$7”, meaning I can’t have more than 6 bars (1 series title, 6 data points).

I am currently trying to adjust the data range of the table with: chart.ChartData.SetRange($“Sheet1!$A$1:$B${LastRow}”) and the number of rows adjusts to fit the new range, but all formatting of the chart is also reset to the default formatting and all of my template style is lost.

I am looking for a way to avoid losing the template formatting or for an easy way to copy over the styles from the template to the new range for Bar/Pie/Graph/etc. charts. I have at least one of each chart type in this project, so the solution needs to be universal.

If more info is needed, please contact me.


I have observed the information shared by you and have not been able to completely understand that. Can you please share your requirements in the form of desired output presentation along with.

As far as your above requirement is concerned, Aspose.Slides allows you to add more data series and categories in chart during execution. I suggest you to please visit this documentation link for your convenience.