PivotTableCollection Interface
A collection of all PivotTable objects in the worksheet.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v17.2.Core.dll
Declaration
public interface PivotTableCollection :
ISimpleCollection<PivotTable>,
IEnumerable<PivotTable>,
ICollection,
IEnumerable
Related API Members
The following members accept/return PivotTableCollection objects:
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
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheet-pivot-table-api-t298650
Worksheet sourceWorksheet = workbook.Worksheets["Data1"];
Worksheet worksheet = workbook.Worksheets.Add();
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a pivot table using the cell range "A1:D41" as the data source.
PivotTable 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"]);