如何使用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
向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屋!