We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

"Index was out of range..." error when refreshing PivotTable


Could I get some help in an issue please; we are getting an error when we refresh a pivot table containing a filter. It seems to be getting an error on the “PivotTable.CalculateData()” call after the call on “PivotTable.RefreshData()”. NOTE: The source table has been cleared of data from the second data row downwards before the pivot table is refreshed (Source table is therefore empty, apart from formatting in the first datarow + formulas).

I have attached a small project to demonstrate the issue.
I have also attached an input excel file “inputFile.xlsx” to use on this project. This generates an excel file called “generatedFile.xlsx”.

Also, I was wondering if there is a way for the pivot table to be cleared but maintaining the filters?

I have tried to get the filters from the pivot table using:
PivotFilterCollection coll = pivotTable.PivotFilters;
Clearing the filters of the pivot table before the “CalculateData()” call using:
Followed by re-adding the filters into the pivot table after the “CalculateData()” call using:
if(coll.Count > 0)
foreach(PivotFilter filter in coll)
pivotTable.PivotFilters.Add(filter.FieldIndex, filter.PivotFilterType);
I did the above in the attempt to workaround the error message (as it only seems to error if there are filter fields), however, “pivotTable.PivotFilters” seems to be empty.


Thanks for the sample project with the template file.

I can observe the issue as you have mentioned by using your project with your template file. I found the exception: “Index was out of range” while running your project and executing the codes for refreshing pivot table.

I have logged a ticket with an id “CELLSNET-41703” for your issue. We will look into your issue soon.
Once we have any update on it, we will let you know here.

Thank you.


Thanks for your posting and using Aspose.Cells for .NET.

We have fixed the issue.

Please download and try this fix: Aspose.Cells for .NET v7.4.3.4 and let us know your feedback.


Thank you for providing the fix for the issue.
I have however found a different bug that we could get to before; Now that the file is generated successfully, we found that the pivot table filter’s text is copied to the cells below it. The thread for this is here


Good to know that your issue is resolved by the new fix v7.4.3.4.

For your other issue, we already found it and logged into our database. Please follow up your other thread (<a href="https://forum.aspose.com/t/93433) for updates. Hopefully, we will resolve that issue soon and provide you the fix there.

Thank you.

The issues you have found earlier (filed as CELLSNET-41703) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.