Removing all data from a chart does not update the chart layout (OP-95791)

Hi Support,
After removing all rows containing data from a chart, the layout of the chart does not change and is displayed as still having data.
I am attaching a simple program to replicate the problem.

Br,
Andrea

OP-95791.zip (23.9 KB)

@andreagasparin,

Thanks for the template XLSX file.

When source rows are removed where cells in those rows are already set for a chart’s data source, the cells range will be calculated/taken as “#REF!” in MS Excel, you may confirm this by manually removing those rows in MS Excel. However, you are right layout is not updated accordingly of the chart in the output (by Aspose.Cells) Excel file. The reason might be since “#REF!” denotes reference error which cannot be resolved. MS Excel does change chart’s layout a bit (which is still using some older data). I think you may simply set series and category data to null or empty string to change its layout a bit. See the following lines of code that you may try to add before saving the Excel file
e.g.
Sample code:

....
wbSample.Worksheets[0].Charts[0].NSeries[0].Values = null;
wbSample.Worksheets[0].Charts[0].NSeries.CategoryData = String.Empty;
......

Hope, this helps a bit.

Hi Amjad,
Thank you for your suggestion.

@andreagasparin,

You are welcome.