Hi
The code you provided worked for pre-selecting values in one filter but when there are multiple filters for the pivot it doesn’t work. The following is part of a code in which I am trying to set the values in four filters. What is wrong in this code? Secondly what is the role of CalculateData()? Should CalculateData be used for each PageField being set:
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, 45);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Column, 30);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 30);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 38);
//pwkSheet.PivotTables[pvtIndex].RefreshDataFlag = true;
pwkSheet.PivotTables[pvtIndex].ColumnFields.Add(pwkSheet.PivotTables[pvtIndex].DataField);
// pwkSheet.PivotTables[pvtIndex].CalculateData();
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "A");
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "B");
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "C");
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "D");
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "E");
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, "F");
//Access second pivot/pagefield
PivotField pf = pivotTable.PageFields[0];
//Set index of item to select
pf.CurrentPageItem = 1;
//Access second pivot/pagefield
PivotField pf1 = pivotTable.PageFields[1];
//Set index of item to select
pf1.CurrentPageItem = 1;
////Refresh and calculate data... it is important
pivotTable.RefreshData();
pivotTable.CalculateData();