哈喽,大家好,我是木头左!

openpyxl中的条件格式

openpyxl中,可以使用ConditionalFormatting类来创建和管理条件格式。这个类有两个主要的方法:add_conditional_formatting()remove_conditional_formatting(),分别用于添加和删除条件格式。

add_conditional_formatting()

add_conditional_formatting()方法接受一个参数,这是一个字典,包含了条件格式的各种设置。这个字典可以包含以下键:

  • type: 条件格式的类型,可以是"cellIs"、“colorScale”、“dataBar”、“iconSet”、“patternFill”、“topBottomRule"或"leftRightRule”。
  • operator: 条件格式的操作符,例如"greaterThan"、“lessThan”、"equalTo"等。
  • formula1: 条件格式的公式1,通常是一个比较表达式。
  • formula2: 条件格式的公式2,如果需要的话。
  • stopIfTrue: 如果为True,则当条件满足时停止应用条件格式。
  • priority: 条件格式的优先级

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部