The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

PivotDataField Interface

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

Namespace: DevExpress.Spreadsheet

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

Declaration

public interface PivotDataField : PivotFieldReferenceBase
Public Interface PivotDataField
    Inherits PivotFieldReferenceBase
public interface PivotDataField : PivotFieldReferenceBase
Public Interface PivotDataField
    Inherits PivotFieldReferenceBase

Remarks

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.
pivotTable.RowFields.Add(pivotTable.Fields("Product"))
' Add the "Category" field to the column axis area.
pivotTable.ColumnFields.Add(pivotTable.Fields("Category"))
' 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.
pivotTable.PageFields.Add(pivotTable.Fields("Region"))

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