kag0
kag0

Reputation: 6054

get and update cells in individual google sheet (specific sheet in spreadsheet)

Google spreadsheets are made up of one or more individual sheets (shown as tabs on the bottom of the web ui). The v4 sheets api makes it fairly clear how to to manipulate cells in the default sheet in a spreadsheet, but I can't seem to figure out how to specify a different sheet for read/write operations.

Any information on how to do this with the java or rest api would be appreciated.

Upvotes: 0

Views: 2638

Answers (1)

Tanaike
Tanaike

Reputation: 201368

In the case of use for reading (values.get) and writing (values.update) data to cells for the existing Spreadsheet, you can use the specific sheet in the Spreadsheet using A1 notation for Range. The detail information of A1 notation is here.

Read operation : values.get

About values.get of Sheets API v4 which is used for retrieving cell values in the sheet, You can see the sample script at here.

In the sample script, you can retrieve the cell values by modifyingString spreadsheetId = "my-spreadsheet-id"; and String range = "my-range";. For example, Sheet2!A1:B2 for the range retrieves the first two cells in the top two rows of Sheet2.

Write operation : values.update

About values.update of Sheets API v4 which is used for updating cell values in the sheet, You can see the sample script at here.

In the sample script, you can update the cell values by modifying like the same to above.

Note :

If you use sample script, at first, please check Quickstart. After that, please check TODO in the sample script.

If I misunderstand your question, I'm sorry.

Upvotes: 2

Related Questions