首页 > 解决方案 > Excel 中的条件格式 +1

问题描述

我想将条件格式应用于包含 +1 的所有单元格。为了避免 Excel 将 +1 转换为 1,我使用了 '+1. 但是,下面的代码不起作用。任何想法为什么?

my_formats = {-1: '#FF0000',
              "'+1": '#00FF00',}

for val, color in my_formats.items():
    fmt = workbook.add_format({'font_color': color})
    worksheet.conditional_format('B3:EK500', {'type': 'cell',
                                           'criteria': '=',
                                           'value': val,
                                           'format': fmt})

标签: pythonexcelxlsx

解决方案


推荐阅读