.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

PivotField.SortType Property

Gets or sets the type of sort to apply to the PivotTable field.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll

Declaration

PivotFieldSortType SortType { get; set; }

Property Value

Type Description
PivotFieldSortType

One of the PivotFieldSortType enumeration values specifying the sort order.

Remarks

Use the SortType property to sort item labels in a specific row, column or page field in a PivotTable report in ascending or descending order. Sort options are available using the PivotField.Sort property.

The following example sorts items of the “Product” field in ascending order.

Dim worksheet As Worksheet = workbook.Worksheets("Report1")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access the pivot field by its name in the collection.
Dim field As PivotField = pivotTable.Fields("Product")
' Sort items in the "Product" field. 
field.SortType = PivotFieldSortType.Ascending

You can also sort a row or column field based on values in a data field. To do this, use the PivotField.SortItems method.

See Also