Select existing chart from excel worksheet


I’m trying to modify a chart from an opened excel worksheet. There is only one chart in the worksheet.

My code is simple, but the “chart.Count” returns me a zero. Pls advise me the correct way to select the chart if I’m wrong. Thx a lot!

My testing code:
Charts chart = excel.Worksheets[RCHART_WORKSHEET_NUM].Charts;
int size = chart.Count;



Hi Bonnie,

Currently Aspose.Excel doesn’t allow you to modify a chart in your designer file. You can only change the data of the chart.

For example, chart data source is A1:B5, you can modify the data in A1 to B5. Then the chart in the result file will reflect this change.


Hi Laurence,
This is my scenario, I have an excel file (a template for my program), with a chart in one worksheet and it’s datasource in another. In my program, I will update the data of the chart’s datasource and the chart will reflect the changes. I already got this and it is working fine. However, there is another thing i need to do is that I need to change the Chart Title as well as the title, Min n Max value of the X/Y Axis.

I saw some code from this forums:

chart.CategoryAxis.Title.Text = “Kalenderwochen”;
chart.ValueAxis.Title.Text = “Anzahl Fzg. (Anlieferung Montage) pro KW”;

If i’m not wrong, it’s setting the title for X/Y Axis. If this can be done, how do I select my chart from the worksheet to do these setting? I tried “Chart chart = sheet.Charts[0];” but it return a null.

* Is there any alternative if the above cannot be done? Create new Chart in worksheet instead of reading from template?



Hi Bonnie,

If you import designer file with chart, you can only change the data source at run time. If you want to change more of a chart, you have to create the chart from your code.

You can refer to sample. The source code of this sample is copyed in your local machine.