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

Free Support Forum - aspose.com

PivotTable.RefreshData() - Unable to cast object of type 'System.DateTime' to type 'System.String'


When refreshing data in a PivotTable that contain dates (e.g. pivotTable.RefreshData();), I receive the following error:

Unable to cast object of type ‘System.DateTime’ to type ‘System.String’.

Removing cells with DateTime formatted data or changing the format from a date to a number “fixes” the issue with the method call, but not the underlying issue.

Using Aspose Cells .NET

Any suggestions?


Thanks for your posting and using Aspose.Cells.

Please download and try the latest version: Aspose.Cells
for .NET v8.4.1.2
and see if it makes any difference and fixes this issue.

If your issue still occurs, then please provide us your sample code and source excel file that we could use to replicate this issue at our end. We will look into it and help you asap.

Unfortunately, the issue persists along with the issue posted here:

Chart.RefreshPivotData() - Incorrect Labels/Legend

I’ve included the code, the Excel document sample, the generated chart image (incorrect legend) and a screenshot of what the image should look like.

Note that when removing the date information from the table, pivot table and slicer, the code works.

Thank you very much for the assistance!

Hi Nate,

Unfortunately, we are unable to extract the sample spreadsheet from your attached archive as it seems to be corrupted. I have tried with WinRAR as well as Windows built-in archive explorer to extract the sample. Could you please attach the individual files again so we may re-evaluate your presented scenario?

Sorry about that. I’ve included each item separately, though the main program has had extension changed to .txt to ensure I could upload it here.

Thanks again for the help!


Thanks for your posting and using Aspose.Cells.

We were able to observe this exception after executing your sample code with your source excel file using the latest version: Aspose.Cells
for .NET v8.4.1.3
. Refreshing the pivot table causes invalid string cast exception as you mentioned.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43629 - PivotTable.RefreshData() - Unable to cast object of type ‘System.DateTime’ to type ‘System.String’

Great! Thank You.

Does this involve the chart issue reported at the following:
Chart.RefreshPivotData() - Incorrect Labels/Legend

Or do I need to resubmit the same files?


Thanks for your posting and using Aspose.Cells.

Please submit your post, code and files in that thread i.e

( Chart.RefreshPivotData() - Incorrect Labels/Legend )

The code which you have submitted in this thread generates the exception, please submit the code that we could run successfully and replicate the issue in that thread.

Thank for your cooperation.


Please try our latest version/fix: Aspose.Cells for .NET v8.5.1.3

We have fixed your issue "CELLSNET-43629" now.

Let us know your feedback.

Thank you.

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

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