Google Spreadsheets API如何使用数据插入新列

问题描述 投票:0回答:1

我正在尝试在“年龄”列之后插入一个包含新数据数组的新列。

enter image description here

[从herehere开始,我明白了:

curl --location --request POST 'https://sheets.googleapis.com/v4/spreadsheets/{my_ID}/values/Sheet1!A1:C2:append?insertDataOption=OVERWRITE&valueInputOption=USER_ENTERED' \
--header 'Authorization: Bearer {my_AUTH_TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "majorDimension": "COLUMNS",
    "values": [
        ["Last Name", "Unknown"]
    ]
}'

但是,它一直在这样做:

enter image description here

我要在["Last Name", "Unknown"]列中插入D而不是A3。关于如何解决这个问题的任何提示?

curl google-sheets spreadsheet google-sheets-api
1个回答
0
投票
  • 您想使用Sheets API将"Last Name""Unknown"的值放入“ D”列的行中。
  • 您想使用curl实现。
  • 您已经能够使用Sheets API获取和放置Google Spreadsheet的值。

如果我的理解正确,那么这个答案如何?请认为这只是几个可能的答案之一。

修改点:

  • [当您要将"Last Name""Unknown"的值放入“ D”列的行时,请使用[["Last Name"],["UnKnown"]]而不是[["Last Name", "Unknown"]]

模式1:

在此模式下,使用电子表格.values.append的方法。

curl --request POST \
  'https://sheets.googleapis.com/v4/spreadsheets/{my_ID}/values/Sheet1!D1:append?valueInputOption=USER_ENTERED' \
  --header 'Authorization: Bearer {my_AUTH_TOKEN}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"values":[["Last Name"],["UnKnown"]]}'

模式2:

在此模式下,使用电子表格.values.update的方法。

curl --request PUT \
  'https://sheets.googleapis.com/v4/spreadsheets/{my_ID}/values/Sheet1!D1?valueInputOption=USER_ENTERED' \
  --header 'Authorization: Bearer {my_AUTH_TOKEN}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"values":[["Last Name"],["UnKnown"]]}'

参考:

如果我误解了你的问题,而这不是你想要的方向,我深表歉意。

© www.soinside.com 2019 - 2024. All rights reserved.