Hi,
Could I get some help in an issue please; we are getting an error when we refresh a pivot table containing a filter. It seems to be getting an error on the “PivotTable.CalculateData()” call after the call on “PivotTable.RefreshData()”. NOTE: The source table has been cleared of data from the second data row downwards before the pivot table is refreshed (Source table is therefore empty, apart from formatting in the first datarow + formulas).
I have attached a small project to demonstrate the issue.
I have also attached an input excel file “inputFile.xlsx” to use on this project. This generates an excel file called “generatedFile.xlsx”.
Also, I was wondering if there is a way for the pivot table to be cleared but maintaining the filters?
I have tried to get the filters from the pivot table using:
PivotFilterCollection coll = pivotTable.PivotFilters;Clearing the filters of the pivot table before the “CalculateData()” call using:
pivotTable.PivotFilters.Clear();
Followed by re-adding the filters into the pivot table after the “CalculateData()” call using:
if(coll.Count > 0)
{
foreach(PivotFilter filter in coll){
pivotTable.PivotFilters.Add(filter.FieldIndex, filter.PivotFilterType);
}
}I did the above in the attempt to workaround the error message (as it only seems to error if there are filter fields), however, “pivotTable.PivotFilters” seems to be empty.