.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

PivotFieldReference Interface

Represents a reference to a PivotField object that is currently shown as a row or column field.

Namespace: DevExpress.Spreadsheet

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


public interface PivotFieldReference :


The PivotFieldReference object is a member of the PivotFieldReferenceCollection collection, which represents either a collection of row fields (if it is accessed using the PivotTable.RowFields property) or a collection of column fields (if it is accessed using the PivotTable.ColumnFields property). An individual row or column field defined by the PivotFieldReference object can be accessed by its name or index in the corresponding collection using the PivotFieldReferenceCollection.Item property.

By default, the newly created pivot table contains no row or column fields. To add a PivotField to the row or column area of the PivotTable report, use the PivotFieldReferenceCollection.Add method.

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 re-order fields in the row or column area, use the PivotFieldReferenceBase.MoveDown, PivotFieldReferenceBase.MoveUp, PivotFieldReferenceBase.MoveToBeginning or PivotFieldReferenceBase.MoveToEnd method of the PivotFieldReference object whose position you wish to change.

To remove a row or column field from the pivot table, use the PivotFieldReferenceCollection.Remove or PivotFieldReferenceCollection.RemoveAt method.

See Also