基于单元格的openpyxl条件格式
openpyxl conditonal formatting based on cell
我正在使用 CellIs 类型的 openpyxl conditonal_formatting,所以我可以:
rule = openpyxl.formatting.rule.CellIsRule(operator='lessThan', formula=['3'], fill=fill)
但我似乎无法将公式设为常量以外的任何东西...如果我尝试输入 'Q1' 它根本不会做任何事情...
fill
的定义是什么?这对我来说很好用:
red_fill = PatternFill(start_color='EE1111', end_color='EE1111', fill_type='solid')
ws.conditional_formatting.add('B1:B5', CellIsRule(operator='greaterThan',
formula=['B3'], fill=red_fill))
之前:
之后:
我正在使用 CellIs 类型的 openpyxl conditonal_formatting,所以我可以:
rule = openpyxl.formatting.rule.CellIsRule(operator='lessThan', formula=['3'], fill=fill)
但我似乎无法将公式设为常量以外的任何东西...如果我尝试输入 'Q1' 它根本不会做任何事情...
fill
的定义是什么?这对我来说很好用:
red_fill = PatternFill(start_color='EE1111', end_color='EE1111', fill_type='solid')
ws.conditional_formatting.add('B1:B5', CellIsRule(operator='greaterThan',
formula=['B3'], fill=red_fill))
之前:
之后: