为了账号安全,请及时绑定邮箱和手机立即绑定

基于单元格的openpyxl条件格式

基于单元格的openpyxl条件格式

12345678_0001 2021-09-14 15:58:00
我正在使用 CellIs 类型的 openpyxl conditonal_formatting,所以我可以这样做:rule = openpyxl.formatting.rule.CellIsRule(operator='lessThan', formula=['3'], fill=fill)但我似乎不能做任何除了常数之外的公式......如果我尝试输入'Q1',它永远不会做任何事情......
查看完整描述

1 回答

?
三国纷争

TA贡献1804条经验 获得超7个赞

什么是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))

前:

//img1.sycdn.imooc.com//6140562a0001881e01650132.jpg

后:

//img1.sycdn.imooc.com//61405630000140d601670131.jpg


查看完整回答
反对 回复 2021-09-14
  • 1 回答
  • 0 关注
  • 322 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信