Spreadsheets API

How to create pivote table in spreadsheets using Advance rest?

@rohini.deshpande Kindly revert to this query. Thanks.

Hi,

You can try using the below API with POST method.

https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID:batchUpdate

along with below body :

{
“requests”: [
{
updateCells”: {
rows”: [
{
values”: [
{
pivotTable”: {
source”: {
“sheetId”:

SOURCE_SHEET_ID

,
“startRowIndex”: 0,
“startColumnIndex”: 0,
“endRowIndex”: 20,
“endColumnIndex”: 7
},
rows”: [
{
“sourceColumnOffset”: 0,
“showTotals”: true,
sortOrder”: “ASCENDING”,
valueBucket”: {
buckets”: [
{
“stringValue”: “West”
}
]
}
},
{
“sourceColumnOffset”: 1,
“showTotals”: true,
sortOrder”: “DESCENDING”,
valueBucket”: {}
}
],
columns”: [
{
“sourceColumnOffset”: 4,
sortOrder”: “ASCENDING”,
“showTotals”: true,
valueBucket”: {}
}
],
values”: [
{
summarizeFunction”: “SUM”,
“sourceColumnOffset”: 3
}
],
valueLayout”: “HORIZONTAL”
}
}
]
}
],
start”: {
“sheetId”:
SHEET_ID

,
“rowIndex”: 49,
“columnIndex”: 0
},
“fields”: “pivotTable”
}
}
]
}