I have evaluated your presented scenario while using the latest version of Aspose.Cells for .NET 8.6.2.2 and following piece of code to replicate the System.IndexOutOfRangeException on my end. I have logged this incident in our bug tracking system as CELLSNET-44089 for further investigation.
Please note, as I do not have access to your database so I have manually copied a few rows of data onto a new worksheet in your provided XLSM and then imported the data from newly created worksheet to the one that serves as data source to the PivotTable and refreshed it.
C#
var book = new Workbook(“C:/temp/output+(6).xlsm”); var dataSheet = book.Worksheets[“Sheet1”]; var data = dataSheet.Cells.ExportDataTable(0, 0, dataSheet.Cells.MaxDataRow + 1, dataSheet.Cells.MaxDataColumn + 1); var pivotData = book.Worksheets[“Hoja3”]; pivotData.Cells.ImportDataTable(data, false, “A1”); foreach (Aspose.Cells.Worksheet worksheet in book.Worksheets) { // worksheet.RefreshPivotTables(); //throws same error foreach (Aspose.Cells.Pivot.PivotTable pivotTable in worksheet.PivotTables) { pivotTable.RefreshDataOnOpeningFile = true; pivotTable.RefreshDataFlag = true; pivotTable.RefreshData(); pivotTable.CalculateData(); //Error pivotTable.RefreshDataFlag = false; } } book.Save(“C:/temp/output.xlsx”, SaveFormat.Xlsx);
The code provided above was used to replicate the IndexOutOfRangeException exception on our side. We have provided it here for your future reference, where the ticket logged against this issue is currently pending for analysis, and is in the queue with other priority tasks. We will let you know of our analysis results as soon as we have completed it.
It is to inform you that we have fixed your issue CELLSNET-44089 now. We will soon provide the fix after performing QA and including other enhancements and fixes.