【发布时间】:2020-12-22 02:17:47
【问题描述】:
基于this question 关于设置颜色,我想知道如何重置/清除 Google 表格标签的颜色。
供参考,这里是如何设置颜色
sheet = open_worksheet() # does all the auth/credential work
new_tab = sheet.worksheet('DemoTab')
body = {
"requests": [
{
"updateSheetProperties": {
"properties": {
"sheetId": new_tab.id,
"tabColor": {
"red": 1.0,
"green": 0.3,
"blue": 0.4
}
},
"fields": "tabColor"
}
}
]
}
try:
res = sheet.batch_update(body)
pprint(res)
except gspread.exceptions.APIError as gea:
pprint(gea.args[0], width=100)
所有文档都声明“tabColor”应该是一个 Color 对象(如上所示,带有红色、绿色和蓝色的字典)。还有一个可选的 alpha。
还有一个“tabColorStyle”参数,但它也在寻找颜色。
我尝试将“tabColor”设置为空字典,{},RGB 分别设置为 0,RGB 设置为 -1。所有最终都只是将颜色变为黑色。
没有提到.clear 选项。
那么,一旦设置了颜色,我该如何去除呢?
这是Google Sheet API 和Sheet properties 的链接,我一直在其中查找请求的外观。
【问题讨论】:
标签: python google-sheets google-sheets-api gspread