Free Support Forum - aspose.com

Calculating Chart on Specific XLS Document Fails with ArgumentOutOfBoundsException

When trying to run chart.Calculate() on a specific chart in a specific .xls file, Aspose is throwing an ArgumentOutOfRangeException. The chart is particularly empty.

Reproduction snippet:

const string filename = "TestData\\NativeExcel\\ChartWithIndexOutOfRange.xls";

var asposeLoadOptions = new LoadOptions(LoadFormat.Auto)
{
	LoadFilter = new LoadFilter(LoadDataFilterOptions.All)
};

using (var workbook = new Workbook(filename, asposeLoadOptions))
{
	workbook.Worksheets[0].Charts[0].Calculate();
}

ChartWithIndexOutOfRange.zip (Client File, reduced to specific issue) (9.3 KB)

@cormack.milyli,
We have reproduced the issue and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNET-47808 - Exception raised while calculating an empty chart

@cormack.milyli,

Since the chart does not have any series data so ArgumentOutOfRangeException will surely occur on trying to call Chart.Calculate. You may easily cope with it by adding an if condition, see the updated code segment for your reference:
e.g
Sample code:

const string filename = "e:\\test2\\ChartWithIndexOutOfRange.xls";

            var asposeLoadOptions = new LoadOptions(LoadFormat.Auto)
            {
                LoadFilter = new LoadFilter(LoadDataFilterOptions.All)
            };

            using (var workbook = new Workbook(filename, asposeLoadOptions))
            {
                Chart chart = workbook.Worksheets[0].Charts[0];
                if (chart.NSeries.Count > 0)
                {
                    workbook.Worksheets[0].Charts[0].Calculate();
                }
                else
                {
                    MessageBox.Show("chart is empty, so you cannot calculate its data");
                }
            }

@cormack.milyli,

We have also fixed the issue so you don’t have to use the if condition. Once the fix is available, we will share it with you.

@cormack.milyli
Please try the latest fix 20.12.6. We have fixed this issue in the fix.

Aspose.Cells20.12.6 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells20.12.6 For .Net4.0.Zip (5.5 MB)
Aspose.Cells20.12.6 For .NetStandard20.Zip (5.5 MB)

The issues you have found earlier (filed as CELLSNET-47808) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao