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

问题描述:

使用Google Sheets API python如何将dropdown list添加到Google表格list items [YES。 NO,MAYBE]邀请朋友是否会参加活动。如何使用Google表格API向Google表格添加下拉列表python

我看着谷歌开发者表api文档HERE并没有提供任何示例。

寻找JSON结构。

其结果将是这样的:

enter image description here

谢谢!

我发现setDataValidation属性内的伎俩,并选择ONE_OF_LISTcondition 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 
    } 
    } 
}, 
内的项目清单