我正在使用http://pygsheets.readthedocs.io/en/latest/index.html一个围绕googlesheetsapiv4的包装器。我对使用googlesheetsapiv4设置条件格式感兴趣。我尝试使用一个自定义公式根据行中“Q”列的值高亮显示行。如果q列包含“垃圾”,我想把这行涂成黄色。在
当我浏览https://github.com/nithinmurali/pygsheets/blob/master/pygsheets/client.py中的pygheets库和sh_批处理更新方法时
import pygsheets
def cfr1(sheetId):
# Apply to range: A1:R
# Format cells if...: Custom formula is
# (formula:) =$Q1="TRASH"
return {
"addConditionalFormatRule": {
"rule": {
"ranges": [
{
"sheetId": sheetId,
"startColumnIndex": 'A',
"endColumnIndex": 'R',
"startRowIndex": 1,
"endRowIndex": 8
}
],
"booleanRule": {
"condition": {
"type": "CUSTOM_FORMULA",
"values": [
{
"userEnteredValue": '=$Q1="TRASH"'
}
]
},
"format": {
"backgroundColor": {
"yellow": 1.0
# "green": 0.0,
# "blue": 0.0
}
}
}
},
"index": 0
}
}
当我跑步时:
^{pr2}$我得到了:
"Invalid JSON payload received. Unknown name "yellow" at 'requests[0].add_conditional_format_rule.rule.boolean_rule.format.background_color': Cannot find field.">
这对绿色、红色和蓝色的原色确实有效。如何格式化为黄色背景。在
不能用黄色作为颜色,它应该是RGB格式,请参见this。所以,对于黄色,你需要红色=1,绿色=1,蓝色=0
相关问题 更多 >
编程相关推荐