We have an Excel sheet we are trying to modify with Aspose. Unfortunately the file is corrupt after saving. To see if the problem is caused by our code or the Aspose code, we have written the following sample program:
var inFile = "C:\\temp\\pivot_in.xlsx";
var outFile = "C:\\temp\\pivot_out.xlsx";
//var lo = new LoadOptions {
// WarningCallback = new WarningCallBack(),
// ParsingFormulaOnOpen = true,
// ParsingPivotCachedRecords = true
//};
var wb = new Workbook(inFile);
//foreach( var s in wb.Worksheets ) {
// foreach( var pt in s.PivotTables ) {
// pt.RefreshDataFlag = true;
// pt.RefreshData();
// pt.CalculateData();
// pt.RefreshDataFlag = false;
// }
//}
wb.Save( outFile, SaveFormat.Xlsx );
When I enable the foreach loop, I receive the following error: Aspose.Cells.CellsException: ‘this data source is not supported.’
When I open the saved file, Excel gives me a warning that the file is corrupted and need to be repaired. After repairing Excel shows the following message: Removed Part: /xl/pivotTables/pivotTable2.xml part with XML error. (PivotTable view) Load error. Line 1, column 0.
pivot_in.zip (874.4 KB)