0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Google スプレッドシートを curl で 代入・更新

Last updated at Posted at 2019-03-03

次のようなスプレッドシートを作成します。
spread_mar0303.png

ACCESS_TOKEN="*****"
SPREADSHEET_ID="*****"
URL="https://sheets.googleapis.com/v4/spreadsheets/"
#
curl -H "Authorization: OAuth "$ACCESS_TOKEN \
        -X POST -H "Content-Type: application/json" \
        $URL$SPREADSHEET_ID:batchUpdate \
        -d@cities.json
cities.json
{
  "requests": [
    {
      "updateCells": {
        "range": {
            "sheetId": 0,
            "startRowIndex": 0,
            "endRowIndex": 3,
            "startColumnIndex": 0,
            "endColumnIndex": 5
        },
        "rows": [
            {
              "values": [
                { "userEnteredValue": { "stringValue": "t2001"} },
                { "userEnteredValue": { "stringValue": "小山"} },
                { "userEnteredValue": { "numberValue": 82345} },
                { "userEnteredValue": { "boolValue": false} },
                { "userEnteredValue": { "stringValue": "2017-3-12"} }
            ]
          },
            {
              "values": [
                { "userEnteredValue": { "stringValue": "t2002"} },
                { "userEnteredValue": { "stringValue": "下野"} },
                { "userEnteredValue": { "numberValue": 31845} },
                { "userEnteredValue": { "boolValue": false} },
                { "userEnteredValue": { "stringValue": "2018-9-19"} }
            ]
          },
            {
              "values": [
                { "userEnteredValue": { "stringValue": "t2003"} },
                { "userEnteredValue": { "stringValue": "栃木"} },
                { "userEnteredValue": { "numberValue": 93726} },
                { "userEnteredValue": { "boolValue": false} },
                { "userEnteredValue": { "stringValue": "2014-3-22"} }
            ]
          }
        ],
        "fields": "userEnteredValue"
      }
    }
  ]
}

アクセストークンの作成方法はこちら
Google スプレッドシートを curl で扱う

シートを読む方法
Google スプレッドシートを curl で読む

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?