Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sheet API append to a specific sheet

according to the API it seems that I can't specify the sheet where to append the data. It appends everything in the first sheet. Is it really like this?

Beacuse I can create a file with multiple sheets, but then I can't write on the second sheet?

like image 447
EsseTi Avatar asked Dec 09 '16 19:12

EsseTi


1 Answers

The solution is to specify the sheet title in the {range} parameter found on the awful-as-always Google Sheets API docs.

Below are the request deets on a updating the value on sheet2...

URL:

PUT https://sheets.googleapis.com/v4/spreadsheets/{someSpreadsheetId}/values/sheet2!A1:D3?valueInputOption=USER_ENTERED

BODY:

{
  "values": [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
  ]
}

Note that the title of the second sheet, "sheet2" prepends what I would have considered the range: "A1:D3" with an exclamation delimiter. sheet2!A1:D3

like image 97
Peter James Chang Avatar answered Oct 10 '22 14:10

Peter James Chang