pands使用openpyxl引擎实现EXCEL条件格式

通过python的openpyxl库,实现公式条件格式。

实现内容:D列单元格不等于E列同行单元格时标红。

#重点是formula=后面的公式不需要"="号。

python 复制代码
from openpyxl.styles import Color, PatternFill, Font, Border
from openpyxl.styles.differential import DifferentialStyle
from openpyxl.formatting.rule import ColorScaleRule, CellIsRule, FormulaRule, Rule

    redFill = PatternFill(start_color='EE1111',
               end_color='EE1111',
               fill_type='solid')
#重点是formula=后面的公式不需要"="号。
    ws.conditional_formatting.add('D3:E7',FormulaRule(formula=['$D3<>$E3'],stopIfTrue=True,fill=redFill))

官方文档参考:条件格式 --- openpyxl 3.0.5 文档

相关推荐
开开心心就好1 天前
体积小巧的图片重复查找工具推荐
linux·运维·服务器·智能手机·自动化·excel·fabric
2301_803875611 天前
如何高效实现多用户通知系统而不造成数据库冗余
jvm·数据库·python
weixin_580614001 天前
SQL如何统计分组内的最高和最低值_MAX与MIN聚合应用
jvm·数据库·python
DevangLic1 天前
【量化-因子】
python
baidu_340998821 天前
JavaScript中函数调用的四种模式及其this绑定优先级表
jvm·数据库·python
吕源林1 天前
SQL在JOIN语句中过滤非必要字段_减少传输开销与查询执行时间
jvm·数据库·python
qq_424098561 天前
如何在 Go 方法中正确修改切片类型
jvm·数据库·python
qq_334563551 天前
如何利用分区进行并行DML_开启会话并行针对不同分区同时执行更新
jvm·数据库·python
z4424753261 天前
如何高效进行堆叠分类器的超参数调优:解决 GridSearchCV 卡顿问题
jvm·数据库·python
2301_775148151 天前
如何操作 XML 数据_XMLTYPE 与 EXTRACT 函数解析节点
jvm·数据库·python