如何使用 Google Sheets API python 添加下拉列表到 google sheet

How to add a dropdown list to google sheet using Google Sheets API python

使用 Google Sheets API python 如何使用 list items 添加 dropdown list 到 google sheet [是。不,也许] 邀请朋友询问他们是否会参加活动。

我查看了 google 开发人员 sheet 的 api 文档 HERE,但没有提供示例。

正在寻找 JSON 结构。

结果会是这样的:

谢谢!

我在 setDataValidation 属性 中找到了诀窍并选择 ONE_OF_LIST 作为 condition type 我所要做的就是提供 ONE_OF_LIST 中的项目列表=14=] 列表

{
  "setDataValidation": {
    "range": {
      "sheetId": sheet_id,
      "startRowIndex": 1,
      "endRowIndex": 1,
      "startColumnIndex": 22,
      "endColumnIndex": 23
    },
    "rule": {
      "condition": {
        "type": 'ONE_OF_LIST',
        "values": [
          {
          "userEnteredValue": 'YES',
          },
          {
          "userEnteredValue": 'NO',
          },
          {
          "userEnteredValue": 'MAYBE',
          },
        ],
      },
      "showCustomUi": True,
      "strict": True
    }
  }
},