Create Pivot Table

Create Pivot Table

Create Pivot Table Using Aspose.Cells

Creating a Simple Pivot Table

To create a pivot table using Aspose.Cells, please follow the steps below:

  1. Add some data to worksheet cells by using the Cell object’s setValue method. This data will be used as a data source for the pivot table.
  2. Add a pivot table to the worksheet by calling the add method of the PivotTableCollection class, encapsulated in the Worksheet object.
  3. Access the PivotTable object from the PivotTableCollection by passing the PivotTable index.
  4. Use any of the pivot table objects (explained above) encapsulated in the PivotTable object to manage the pivot table.

The code example below shows how to create a simple pivot table following the basic steps listed above. When executing the code, a pivot table is added to the worksheet:

Creating a pivot table based on a corresponding field