Calculating charts on an empty chart with a title errors


#1

Hi,

When calling chart.Calculate() on an empty chart that has an empty auto-text title, Aspose will throw an Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index error. We’ve seen a few documents that have charts with this case unfortunately.

Repro code:

var format = FileFormatUtil.DetectFileFormat("3DPieChartWithAutoTitle.xlsx");

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

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

I’ve attached an example file.

Thanks!
3DPieChartWithAutoTitle.zip (10.0 KB)


#2

@bvk,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46965 - Calculating charts on an empty chart with a title errors

#3

@bvk,

Since there is no data series found for the chart, so you may get such an exception. Well, you may easily cope with it or handle the exception, see the sample code segment for your reference:
e.g
Sample code:

var format = FileFormatUtil.DetectFileFormat("e:\\test2\\3DPieChartWithAutoTitle.xlsx");

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

            using (var workbook = new Workbook("e:\\test2\\3DPieChartWithAutoTitle.xlsx", asposeLoadOptions))
            {
                if (workbook.Worksheets[0].Charts[0].NSeries.Count == 0)
                {
                    //do not calculate the chart as it has no data series.
                   //your code goes here.
                   //.........  
                }
                else
                {
                    workbook.Worksheets[0].Charts[0].Calculate();
                }
            }
        }

Hope, this helps a bit.


#4

@Amjad_Sahi

Does .Calculate() only affect the NSeries data in a chart? My worry would be that there was some other attributes in PlotArea or someplace else a formula wasn’t getting calculated


#5

@bvk,

No, it may also affect plot area and other chart objects and items.

Since we have already logged a ticket with an id “CELLSNET-46965” for your issue. So, kindly spare us little time (3-5 days or so) to evalute and fix your issue.

Once we have an update on your issue, we will let you know.


#6

Sorry, yes, that workaround is great to have for now, was just curious about other implications of calculating.

Thanks for the update!


#7

@bvk,
You are welcome. Once we will have some news for you, we will update you in this topic.


#8

@bvk,

Please try our latest version/fix: Aspose.Cells for .NET v19.10.3 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.10.3 For .Net2_AuthenticodeSigned.Zip (5.0 MB)
Aspose.Cells19.10.3 For .Net4.0.Zip (5.0 MB)


#9

@Amjad_Sahi,

I can confirm that fixes the issues for docs we were seeing that error on. Thanks!


#10

@bvk,

Good to know that your issue is resolved with the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.


#11

The issues you have found earlier (filed as CELLSNET-46965) have been fixed in Aspose.Cells for .NET v19.11. This message was posted using Bugs notification tool by Amjad_Sahi