System.ArgumentOutOfRangeException calling CalculateData with collapsed row columns

In an Excel file I have a pivot table with a named range as datasource. The pivot table has 3 values (measure) and year, quarter and month in columns. I import data into the datasheet, update the named range and call RefreshData and CalculateData on the pivot table.

If I collapse either year or quarter I get a System.ArgumentOutOfRangeException exception when calling CalculateData.

If I expand year and quarter CalculateData does not produce an exception.

Can I in code expand all column fields then call CalculateData and then collapse all/some column fields again?

It appears as if only when the pivot has multiple Values does the exception occur

@mortenma,

Thanks for providing us some details.

Could you provide us template file containing PivotTable (with either year or quarter collapsed) and sample code (runnable) to show the issue, we will check it soon.