我正在尝试实现数据验证,其中规则是使用 Google Sheets API 的范围之一。
在 sheet1 中,我有一个主列表,其中一列需要位于其中一个值中。可能的下拉值位于称为下拉列表的单独工作表中。
我的 one_of_range 条件值的错误是什么?
dropdown_action = {
'setDataValidation':{
'range':{
'startRowIndex':1,
'startColumnIndex':4,
'endColumnIndex':5
},
'rule':{
'condition':{
'type':'ONE_OF_RANGE',
'values': [
{ "userEnteredValue" : "dropdown!A1:B2"
}
],
},
'inputMessage' : 'Choose one from dropdown',
'strict':True,
'showCustomUi': True
}
}
}
request = [dropdown_action]
batchUpdateRequest = {'requests': request}
SHEETS.spreadsheets().batchUpdate(spreadsheetId = id,
body = batchUpdateRequest).execute()
Run Code Online (Sandbox Code Playgroud)
但是,我遇到了http错误。如果我选择列表之一而不是 one_of_range,我就能让它工作。但我更喜欢使用 one_of_range 以便我可以在同一个电子表格中维护可能的值。
请求https://sheets.googleapis.com/v4/spreadsheets/id:batchUpdate?alt=json时出现 HttpError 400返回“无效请求 [1].setDataValidation: Invalid ConditionValue.userEnteredValue: dropdown!A1:B2">
| 归档时间: |
|
| 查看次数: |
1582 次 |
| 最近记录: |