Skip to main content
Row

PivotDataFieldCollection.Insert(Int32, PivotField, String, PivotDataConsolidationFunction) Method

Inserts a field into the data area of a PivotTable report at the specified position.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

PivotDataField Insert(
    int index,
    PivotField field,
    string name,
    PivotDataConsolidationFunction summarizeValuesBy
)

Parameters

Name Type Description
index Int32

A zero-based index that specifies where to insert the data field.

field PivotField

A field that should be added to the data area.

name String

A name for the data field. This value is assigned to the PivotDataField.Name property.

summarizeValuesBy PivotDataConsolidationFunction

A summary function used to calculate values in the data field. This value is assigned to the PivotDataField.SummarizeValuesBy property.

Returns

Type Description
PivotDataField

The data field added to the pivot table.

Exceptions

Type Description
ArgumentOutOfRangeException

Occurs when the index parameter is out of range. It must be non-negative and less than the number of elements in the collection.

Remarks

Use this Insert method to add a new field to the data area at the specified position and specify a summary function used to calculate field values. The PivotDataField.ShowValuesWithCalculation method allows you to apply an additional calculation option to the data field and specify how summary values are displayed within the field.

Reorder Data Fields

Use the PivotDataField.MoveDown, PivotDataField.MoveUp, PivotDataField.MoveToBeginning, and PivotDataField.MoveToEnd methods to reorder fields in the data area. The PivotLayout.DataOnRows property allows you to change the orientation of multiple data fields in the report.

Remove Data Fields

Use the PivotDataFieldCollection.Remove or PivotDataFieldCollection.RemoveAt method to remove a data field from a pivot table. The PivotDataFieldCollection.Clear method removes all fields from the data area.

See Also