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

PivotDataField Interface

Represents a reference to a PivotField object that is currently shown as a data field.

Namespace: DevExpress.Spreadsheet

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


public interface PivotDataField :
Public Interface PivotDataField
    Inherits PivotFieldReferenceBase


The PivotDataField object is a member of the PivotDataFieldCollection collection, which stores all data fields of a PivotTable report. An individual PivotDataField object can be accessed by its name or index in the collection using the PivotDataFieldCollection.Item property.

To add a PivotField to the data area of the PivotTable report, use the PivotDataFieldCollection.Add method. To change the default summary function used by the data field, use the PivotDataField.SummarizeValuesBy property. To apply an additional calculation option to the data field and change the way summary values are displayed within the field, use the PivotDataField.ShowValuesWithCalculation method overloads. To apply a number format to the data field, use the PivotDataField.NumberFormat property.

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.

To change the position of a field within the data area, use the PivotDataField's PivotFieldReferenceBase.MoveDown, PivotFieldReferenceBase.MoveUp, PivotFieldReferenceBase.MoveToBeginning or PivotFieldReferenceBase.MoveToEnd method.

To remove a data field from the pivot table, use the PivotDataFieldCollection.Remove or PivotDataFieldCollection.RemoveAt method.

See Also