![]() Set the default style for the pivot table. PivotTable pivotTable = (cache, worksheet) Create a pivot table based on the specified PivotTable cache. ![]() (pivotTable.Fields("Sales"))Ĭreate a Pivot Table based on the PivotTable Cache ' Add the "Sales" field to the data area. ' Add the "Product" field to the row axis area. ' Add the "Category" field to the row axis area. ' Create a pivot table using the cell range "A1:D41" as the data source.ĭim pivotTable As PivotTable = (sourceWorksheet("A1:D41"), worksheet("B2")) (pivotTable.Fields) ĭim sourceWorksheet As Worksheet = workbook.Worksheets("Data1")ĭim worksheet As Worksheet = () Add the "Sales" field to the data area. Add the "Product" field to the row axis area. Add the "Category" field to the row axis area. PivotTable pivotTable = (sourceWorksheet, worksheet) Create a pivot table using the cell range "A1:D41" as the data source. Worksheet sourceWorksheet = workbook.Worksheets Use the PivotDataFieldCollection.Add method of the PivotTable.DataFields collection.Ĭreate a Pivot Table Using a Cell Range as the Data Source Use the PivotPageFieldCollection.Add method of the PivotTable.PageFields collection. Use the PivotFieldReferenceCollection.Add method of the PivotTable.ColumnFields collection. Use the PivotFieldReferenceCollection.Add method of the PivotTable.RowFields collection. ![]() To add a field to the PivotTable report, access the required field by its name in the collection (by default, field names originate from the column labels in the source range) and move it to one of four PivotTable areas, listed in the table below. All pivot fields are stored in the PivotFieldCollection collection returned by the PivotTable.Fields property. To fill the created pivot table with data, add the necessary fields to it. You can use a cell range as the data source for your PivotTable report, or base it on the data cache of the existing pivot table (for details, see PivotCache). To create a new pivot table, use the PivotTableCollection.Add method of the Worksheet.PivotTables collection accessed for a worksheet where the report should be located. The following examples demonstrate how to use the Pivot Table API to create a pivot table, which summarizes data in a cell range. ![]()
0 Comments
Leave a Reply. |