InsertPivotExistingWorksheet
Inserts the specified pivot table into an existing worksheet.
Syntax
expression.InsertPivotExistingWorksheet(dataRef, pivotRef, confirmation);
expression - A variable that represents a Api class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| dataRef | Required | ApiRange | The source data range. | |
| pivotRef | Required | ApiRange | A range in which the pivot table will be located. | |
| confirmation | Required | boolean | Specifies whether to replace the data in the specified pivot table range (if it exists) or create a dialog box for this (if it exists). |
Returns
Example
Add a pivot table to an existing sheet in a spreadsheet.
// How do I place a pivot table on a sheet that already exists in a spreadsheet?
// Summarize data with a pivot table on the current sheet in a spreadsheet.
let worksheet = Api.GetActiveSheet();
worksheet.GetRange('B1').SetValue('Region');
worksheet.GetRange('C1').SetValue('Price');
worksheet.GetRange('B2').SetValue('East');
worksheet.GetRange('B3').SetValue('West');
worksheet.GetRange('C2').SetValue(42.5);
worksheet.GetRange('C3').SetValue(35.2);
let dataRef = Api.GetRange("'Sheet1'!$B$1:$C$3");
let pivotRef = worksheet.GetRange('A7');
let pivotTable = Api.InsertPivotExistingWorksheet(dataRef, pivotRef);