Rafael Soares - tuelho
Rafael Soares - tuelho

Reputation: 410

Sheets API v4 - JS Client: How to add/append a new row to an existing Sheet

I'm using Google Sheets API v4[1] to manipulate a Spreedsheet using Java Script Client API[2].

How can I add a new row without using the range property of the spreadsheets.values.update method [3]. Is this the only way to add rows using Google Java Script client API?

I just want to add a new row to the end (after last non-empty) of an existing sheet.

Using the rowCount or endRowIndex properties from the sheet object [4] is not an option because I want to add after the last non empty row.

[1] https://developers.google.com/sheets/reference/rest/

[2] https://developers.google.com/sheets/quickstart/js

[3] https://developers.google.com/sheets/reference/rest/v4/spreadsheets.values/update

[4] https://developers.google.com/sheets/reference/rest/v4/spreadsheets#sheet

Upvotes: 2

Views: 2889

Answers (1)

user4426017
user4426017

Reputation: 2000

You can append new row after your last row by using the AppendCellsRequest of the Spreadsheet collection:

https://developers.google.com/sheets/reference/rest/v4/spreadsheets/request#appendcellsrequest

Upvotes: 4

Related Questions