Free Support Forum -

RefreshPivotTables throws error (14.9 KB)

I get an error saying "Unable to cast object of type ‘System.String’ to type ‘System.Double’ with the attached Excel file and just 3 lines of code to open the file and call RefreshPivotTables() using Apose.Cells 20.4.0

var wb = new Aspose.Cells.Workbook(@"C:\Users\Joshua\Downloads\test.xlsx");
var sheet = wb.Worksheets["pivot sheet"];

image.png (34.4 KB)

While it might be possible to get rid of the error by changing the formulas in my workbook, I don’t have the option to modify the formulas in my application’s scenario since they are created by other users, not me. Refreshing the pivot table manually from within Excel works correctly, but not with Aspose.Cells.

Thank you very much,


Thanks for the template file, sample code segment and screenshot.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found an exception “Specified cast is not valid” when refreshing pivot table(s) in the sheet. I have logged a ticket with an id “CELLSNET-47371” for your issue. We will look into it soon.

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

1 Like


Please try our latest version/fix: Aspose.Cells for .NET v20.5.3 (attached)
Aspose.Cells20.5.3 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.5.3 For .Net4.0.Zip (5.4 MB)

Your issue should be fixed in it.

Let us know your feedback.