How same named charts are handled in APSOSE CELL

Hello Team,
I would like to understand how Aspose.Cells handles cases where multiple charts in the same worksheet have the same name.
Specifically, when using the syntax:
worksheet.Charts["chartName"],
which chart will be accessed if there are multiple charts with that same name?
Does it select based on the order from left to right, top to bottom, or some other priority?
This is exceptional case still wanted to understand

@RaghulBabu214

When you have multiple charts with the same name in an Aspose.Cells worksheet and you access them using the syntax worksheet.Charts["chartName"], it will return the first chart it encounters with that name. This behavior occurs because the order of access is based on the internal collection of charts, which typically follows the order in which they were added to the worksheet.

To resolve this issue, you should rename the charts to ensure each one has a unique identifier. This will eliminate any ambiguity when accessing them programmatically and allow you to work with the specific chart you need.

As a next step, review your charts and assign unique names to each one. If you have any further questions or need assistance with the renaming process, feel free to ask!

@RaghulBabu214,

In Aspose.Cells, charts are accessed based on their internal collection order stored in its source, which generally corresponds to the sequence in which they were added to the worksheet. The first one which matches the name will be returned by this method. If you are loading the workbook from template file, the order of those charts was same with the order they are saved in the template file(and in corresponding xml file which describes those charts for xlsx template file)

1 Like