I'm trying to copy Pivot Table rows, where trying to use CalculateData() on the pivot table itself always returns an out of range index exception.
- Code: Select all
//Pivot Table
Spire.Xls.PivotTable pt = sheet.PivotTables.Add("Pivot Table", sheet.Range["A11"], cache);
//Adding Fields-data to the pivot table
var Field1 = pt.PivotFields["Field1"];
Field1.Axis = AxisTypes.Row;
var Field2 = pt.PivotFields["Field2"];
Field2.Axis = AxisTypes.Column;
var dField = pt.PivotFields["data"];
pt.DataFields.Add(dField, "Data", SubtotalTypes.Default);
//Copying desired rows
pt.CalculateData();
sheet.Copy(sheet.Range["A12:C16"], sheet2.Range["A19"]);
I've created another Pivot Table before/above this one where the command works, but unless i remove the previous one, i always get an out of range index error with the 2nd.
Are there not supposed to be 2 pivot tables on the same sheet, is there some sort of cached data i'm supposed to reset, or did i just miss something?
Thank you in advance.