Hi,Im using the following code to refresh all the pivot table in an excel workbook:
//Refresh pivot table in each worksheet
foreach (Aspose.Cells.Worksheet worksheet in workBook.Worksheets)
{
foreach (Aspose.Cells.Pivot.PivotTable pivotTable in worksheet.PivotTables)
{
pivotTable.RefreshData();
pivotTable.CalculateData();
saveFileAtEndOfoperation = true;
}
}
//Refresh pivot table in each worksheet
foreach (Aspose.Cells.Worksheet worksheet in workBook.Worksheets)
{
foreach (Aspose.Cells.Pivot.PivotTable pivotTable in worksheet.PivotTables)
{
pivotTable.RefreshData();
pivotTable.CalculateData();
saveFileAtEndOfoperation = true;
}
}
//save workbook...
It worked the first time it runs, but failed for the second run. I have attached 2 workbook for you to test with. SampleSalespersonReports.xls is the original workbook. SampleSalespersonReports (1).xls is the refreshed workbook.
If you run the refresh against SampleSalespersonReports.xls, it will pass. If SampleSalespersonReports.xls(1), it will fail. If you open SampleSalespersonReports.xls(1) in Excel, there will be a protective view popping up.
Could you check if this is an issue that could be fixed in ASPOSE?
Thanks and regards
Bill