SheetsAPI

Using Request Body of String JSON for Google APIs with googleapis of golang

Gists This is a sample script for directly using the request body of the string JSON for Google APIs with googleapis of golang. At googleapis for golang, when Google API is used, it is required to create the request body like this sample script. I have several contacts for creating about such request body. I thought that such script might be a bit difficult for users. I thought that when the string JSON object is directly used for this, it might be useful.

Setting Number Format of Cells on Google Spreadsheet using batchUpdate in Sheets API with golang

Gists This is a sample script for setting the number format of cells on Google Spreadsheet using batchUpdate in Sheets API with golang. In this case, googleapis for golang is used. The script of the authorization can be seen at the official document. Sample script In this script, the number format of the column “A” is changed to yyyy-mm-dd hh:mm:ss. And, please include https://www.googleapis.com/auth/spreadsheets to the scopes. sheetId := 12345678 // Please set the sheet ID which is not Spreadsheet ID.

Append Values by Inserting Rows using Google Sheets API

Gists In the case appending values to cell by inserting rows, when sheets.spreadsheets.values.append is used, the values are appended to the next empty row of the last row. If you want to append values to between cells with values by inserting row, you can achieve it using sheets.spreadsheets.batchUpdate. When you use this, please use your access token. Endpoint : POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate Request body : In this request body, it appends the data of “sample1, sample2, sample3” to “A1:A3” of the sheetId of “1234567890”.

spreadsheets.values.batchUpdate using Golang

Gists Flow : In my sample script, the script was made using the Quickstart. The flow to use this sample script is as follows. For Go Quickstart, please do Step 1 and Step 2. Please put client_secret.json to the same directory with my sample script. Copy and paste my sample script, and create it as new script file. Run the script. When Go to the following link in your browser then type the authorization code: is shown on your terminal, please copy the URL and paste to your browser.