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

PivotTable.DataFields Property

Provides access to the collection of fields located in the data area of the PivotTable report.

Namespace: DevExpress.Spreadsheet

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


PivotDataFieldCollection DataFields { get; }

Property Value

Type Description

A PivotDataFieldCollection object that represents the collection of data fields.


Use the DataFields property to get access to the collection that stores all data fields added to the PivotTable report. An individual data field is an object of the PivotDataField type, which can be accessed by its index or name in the collection.

To add a data field to the pivot table, use the PivotDataFieldCollection.Add method. To add a field to the data area at the specified position, use the PivotDataFieldCollection.Insert method.

To remove a data field from the PivotTable report, use the PivotDataFieldCollection.Remove or PivotDataFieldCollection.RemoveAt method. You can also use the PivotDataFieldCollection.Clear method to remove all fields from the PivotTable’s data area at once.


Dim sourceWorksheet As Worksheet = workbook.Worksheets("Data1")
Dim worksheet As Worksheet = workbook.Worksheets.Add()
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a pivot table.
Dim pivotTable As PivotTable = worksheet.PivotTables.Add(sourceWorksheet("A1:D41"), worksheet("B2"))

' Add the "Product" field to the row axis area.
' Add the "Category" field to the column axis area.
' Add the "Sales" field to the data area and specify the custom field name.
Dim dataField As PivotDataField = pivotTable.DataFields.Add(pivotTable.Fields("Sales"), "Sales(Sum)")
' Specify the number format for the "Sales" field.
dataField.NumberFormat = "_([$$-409]* #,##0.00_);_([$$-409]* (#,##0.00);_([$$-409]* "" - ""??_);_(@_)"
' Add the "Region" field to the filter area.
See Also