Skip to content

Instantly share code, notes, and snippets.

@cp-sumi-k
Last active November 8, 2022 09:54
Show Gist options
  • Save cp-sumi-k/c39a0c1c89f4ffe6a36f9962853ad342 to your computer and use it in GitHub Desktop.
Save cp-sumi-k/c39a0c1c89f4ffe6a36f9962853ad342 to your computer and use it in GitHub Desktop.
// https://docs.google.com/spreadsheets/d/<SPREADSHEETID>/edit#gid=<SHEETID>
sheetId := <SHEETID>
spreadsheetId := <SPREADSHEETID>
records := []string{"1", "ABC", "abc@gmail.com"}
// create the batch request
batchUpdateRequest := sheets.BatchUpdateSpreadsheetRequest{
Requests: []*sheets.Request{
{
AppendCells: &sheets.AppendCellsRequest{
Fields: "*", // for adding data in all cells
Rows: prepareCells(records), // get formatted cells row
SheetId: int64(sheetId), // use sheetID here
},
},
},
}
// execute the request using spreadsheetId
res, err := srv.Spreadsheets.BatchUpdate(spreadsheetId, &batchUpdateRequest).Context(ctx).Do()
if err != nil || res.HTTPStatusCode != 200 {
log.Error(err)
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment