Dim License As Aspose.Cells.License = New Aspose.Cells.License() License.SetLicense("Aspose.Cells.lic") dim strTemplate as string dim strCopyFile as string strTemplate = "c:\testsheet.xlsx" strCopyFile = "c:\newsheet.xlsx" System.IO.File.Copy(strTemplate, strCopyFile, True) Dim workbook As Workbook = New Workbook(strCopyFile.xlsx) Dim sheetOverview As Worksheet = workbook.Worksheets("Overview") sheetOverview.PivotTables("PivotTable1").RefreshData() workbook.Save(strCopyFile)<a class="attachment" href="/uploads/discourse_instance3/12834">testsheet.zip</a> (397.4 KB)
Thanks for the sample code.
Could you provide us your template Excel file, so we could evaluate your issue precisely.
testsheet.zip (397.4 KB)
Thanks for providing us template file.
After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. I found that Excel file becomes corrupt (MS Excel prompts error messages when opening the file into it) after refreshing the PivotTable:
Workbook workbook = new Workbook("e:\\test2\\Testsheet.xlsx"); Worksheet sheetOverview = workbook.Worksheets["Overview"]; sheetOverview.PivotTables["PivotTable1"].RefreshData(); sheetOverview.PivotTables["PivotTable1"].CalculateData(); sheetOverview.PivotTables["PivotTable1"].CalculateRange(); workbook.Save("e:\\test2\\out1.xlsx");
I have logged a ticket with an id “CELLSNET-46016” for your issue. We will look into it soon.
Once we have an update on it, we will let you know here.
This is to inform you that we have fixed your issue CELLSNET-46016 now. We will soon provide the fix after performing QA and including other enhancements and fixes.
Thanks for using Aspose APIs.
Please download and try the following fix and let us know your feedback.
The issues you have found earlier (filed as CELLSNET-46016) have been fixed in Aspose.Cells for .NET 18.4. Please also check the document/article for your reference: https://docs.aspose.com/display/cellsnet/Installation