【问题标题】:set_data_validation with pygsheets | Python<>Google Driveset_data_validation 与 pygsheets | Python<>谷歌驱动器
【发布时间】:2021-02-08 09:15:16
【问题描述】:

我很难使用 pygsheets 在我的 Google 电子表格文档中设置数据验证。我找到了这个功能:

wks.set_data_validation((startIndex, wks.get_named_ranges("stdArbeitsauftrag").start_addr[1]), condition_type='ONE_OF_RANGE', condition_values='=CONFIG!E3:E')

# wks is my current worksheet
# startIndex is the cell to start
# wks.get_named_ranges("stdArbeitsauftrag").start_addr[1]) should be the same column as in startIndex, but does not work (it works with set_dataframe though) - I will take care of this later
# condition_type='ONE_OF_RANGE' should define a range of values
# condition_values='=CONFIG!E3:E' is the range of value in the same document

调用它会引发 400 文本错误:

返回“无效请求 [0].setDataValidation:ConditionType 'ONE_OF_RANGE' 只需要一个 ConditionValue,但提供了 12 个值。”。详细信息:“无效请求 [0].setDataValidation:ConditionType 'ONE_OF_RANGE' 只需要一个 ConditionValue,但提供了 12 个值。”

有人可以帮忙吗?

最好的问候, 曼努埃尔

【问题讨论】:

    标签: python python-3.x google-sheets google-drive-api pygsheets


    【解决方案1】:

    来自docs,condition_values 应该是一个列表。试试这个

    wks.set_data_validation((startIndex, wks.get_named_ranges("stdArbeitsauftrag").start_addr[1]), condition_type='ONE_OF_RANGE', condition_values=['=CONFIG!E3:E'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      • 2021-09-12
      相关资源
      最近更新 更多