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

PivotPageFieldCollection.Add(PivotField) Method

Adds a field to the report filter area of the pivot table.

Namespace: DevExpress.Spreadsheet

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


PivotPageField Add(
    PivotField field
Function Add(
    field As PivotField
) As PivotPageField


Name Type Description
field PivotField

A PivotField object specifying a pivot field that should be added to the page area of the PivotTable report.


Type Description

A PivotPageField object which represents the inserted page field.


To add a new field to the PivotTable's report filter area at the specified position, use the PivotPageFieldCollection.Insert method. Note that you can also re-order fields in a page area using the MoveDown, MoveUp, MoveToBeginning or MoveToEnd method of the PivotPageField object whose position you wish to change.

To remove a page field from the collection, use the PivotPageFieldCollection.Remove or PivotPageFieldCollection.RemoveAt method. You can also use the PivotPageFieldCollection.Clear method to remove all fields from the PivotTable's report filter area


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