使用 python 比较 excel 中的两列和颜色更大?

compare two columns and color greater in excel using python?

我遇到了条件格式 https://xlsxwriter.readthedocs.io/working_with_conditional_formats.html 但不确定如何实施。 我将结果保存在数据框中,我正在尝试根据 column2> column1 执行此颜色格式设置: 颜色栏 2 其他:什么都不做 并保存 excel 文件。 任何建议。

for row in table:
    ws.write_row(i, 0, row)

    i += 1
    print("for i:", i)
    cell_pointer1 = "C${}".format(i) 
    cell_pointer2 = "D${}".format(i) 
    cell_pointer3 = "E${}".format(i) 
    print("cell pointer2:", format(cell_pointer2))

    ws.conditional_format(format(cell_pointer2) ,
        {'type':     'cell',
         'criteria': '>=',
         'value' : format(cell_pointer1),
         'format':   format2,
        })


    ws.conditional_format(format(cell_pointer2) ,
        {'type':     'cell',
         'criteria': '<',
         'value' : format(cell_pointer1),
         'format':   format1
        })

    ws.conditional_format(format(cell_pointer3) ,
       {'type':     'cell',
        'criteria': '>=',
        'value' : format(cell_pointer1),
        'format':   format2,
       })


    ws.conditional_format(format(cell_pointer3) ,
       {'type':     'cell',
        'criteria': '<',
        'value' : format(cell_pointer1),
        'format':   format1
       })

ws.set_column(0, 0, 25)

wb.close()

   worksheet.conditional_format('B1:B9' ,
                         {'type':'formula',
                          'criteria': '=AND($A1<$B1,$B1>0)',
                          'format':   format1})