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

PivotTableCollection Interface

A collection of all PivotTable objects in the worksheet.

Namespace: DevExpress.Spreadsheet

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

Declaration

public interface PivotTableCollection :
    ISimpleCollection<PivotTable>,
    IEnumerable<PivotTable>,
    IEnumerable,
    ICollection

Remarks

Use the Worksheet.PivotTables property to get access to the PivotTableCollection collection. An individual PivotTable can be accessed by its name or index in the collection.

To create a new pivot table, use the PivotTableCollection.Add method. You can base your pivot table on a cell range or a PivotCache of the existing report.

To remove a specific pivot table from the collection, use the PivotTableCollection.Remove or PivotTableCollection.RemoveAt method.

Example

Dim sourceWorksheet As Worksheet = workbook.Worksheets("Data1")
Dim worksheet As Worksheet = workbook.Worksheets.Add()
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a pivot table using the cell range "A1:D41" as the data source.
Dim pivotTable As PivotTable = worksheet.PivotTables.Add(sourceWorksheet("A1:D41"), worksheet("B2"))

' Add the "Category" field to the row axis area.
pivotTable.RowFields.Add(pivotTable.Fields("Category"))
' Add the "Product" field to the row axis area.
pivotTable.RowFields.Add(pivotTable.Fields("Product"))
' Add the "Sales" field to the data area.
pivotTable.DataFields.Add(pivotTable.Fields("Sales"))
See Also