如何使用Google Sheets API Python将下拉列表添加到Google Sheet [英] How to add a dropdown list to google sheet using Google Sheets API python

查看:471
本文介绍了如何使用Google Sheets API Python将下拉列表添加到Google Sheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google Sheets API python如何使用list items向Google工作表添加dropdown list [是. [NO,MAYBE]邀请参加者,询问他们是否参加活动.

Using Google Sheets API python How to add a dropdown list to google sheet with list items [YES. NO, MAYBE] for an invite asking friends if they will attend an event.

我查看了Google开发人员表格api文档此处,但未提供示例.

I looked at google developer sheets api documentation HERE and no example was provided.

正在寻找JSON结构.

Looking for the JSON structure.

结果将是这样的:

谢谢!

推荐答案

我在setDataValidation属性中找到了窍门,然后选择ONE_OF_LIST作为condition type,而我要做的就是提供其中的项目列表value列表

I found the trick inside the setDataValidation property and choosing ONE_OF_LIST as the condition type and all I had to do is providing the list of items inside the value list

{
  "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
    }
  }
},

这篇关于如何使用Google Sheets API Python将下拉列表添加到Google Sheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆