Skip to main content
Row

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

public interface PivotFieldReference :
    PivotFieldReferenceBase

#Remarks

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.

View Example

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 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