You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mats Alm edited this page Nov 6, 2023
·
6 revisions
You can sort pivot tables by setting the PivotTable Field - Sort property.
rf.Sort=eSortType.Ascending;
This applies to column and row fields.
You can also sort on data fields by using the SetAutoSort method.
rowField.SetAutoSort(df,eSortType.Descending);
This method sets the AutoSort property that contains the pivot area to set for the pivot table field sorting.
If you have multiple row and column fields you can set the auto sort by using pivot areas.
This sample sorts by the column field value "Hardware".
varrowField=p1.RowFields.Add(p1.Fields[0]);varcolumnField=p1.ColumnFields.Add(p1.Fields[1]);vardataField=p1.DataFields.Add(p1.Fields[3]);rf.SetAutoSort(df,eSortType.Descending);varreference=rf.AutoSort.Conditions.Fields.Add(cf);cf.Items.Refresh();//You must refresh the items to fill the items collection with the correct values.reference.Items.AddByValue("Hardware");