如何使用Google表格API python向Google表格添加下拉列表

mon*_*top 1 python excel google-api-client google-sheets-api

使用Google Sheets API python如何dropdown list使用list items[是] 添加到谷歌工作表.不,可能会邀请朋友,他们是否会参加活动.

我在这里查看了google开发者工作表api文档,但未提供任何示例.

寻找JSON结构.

结果将是这样的:

在此输入图像描述

谢谢!

mon*_*top 7

我在setDataValidation属性中找到了这个技巧并选择了ONE_OF_LIST作为condition type我所要做的就是提供列表中的项目value列表

{
  "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
    }
  }
},
Run Code Online (Sandbox Code Playgroud)

  • 值得一提的是,这种类型的数据验证规则不接受超过 500 个元素进入列表。 (2认同)