应用了条件格式(没有错误)但是 sheet 直到我手动转到 'Edit Rules' 才会更新

Conditional formatting is applied (without errors) but sheet doesn't update until I manually go to 'Edit Rules'

条件格式已应用(没有错误),但 sheet 在我手动转到 'Edit Rules' 之前不会更新。

我正在为 value 参数使用 formula 值。公式是正确的。我首先通过在 Excel 中输入它来验证它;而且,这也不会产生任何错误。

ws.conditional_format(1, 0, total_rows, total_columns,
                      {'type'     : 'formula',
                       'criteria' : '=XOR(ISERR(FIND("text1",LOWER($F2))),ISERR(FIND("text2",LOWER($F2))))',
                       'format'   : format1})

只是我必须转到 'Manage Rules',然后编辑规则,然后在 'Edit Rule' 对话框中按确定才能生效。在使用 write_row 将单元格写入 sheet 之前,我尝试移动这部分代码,但这也无济于事。

其他可能相关的代码部分:

total_rows = len(data) - 1
total_columns = len(data[0]) - 1
format1 = wb.add_format({'bg_color': '#FFC7CE', 'font_color': '#9C0006'})

Excel 2010 及以后添加了原始文件规范中未定义的函数。

这些功能被微软称为未来功能。这些函数的示例是 ACOTCHISQ.DIST.RTCONFIDENCE.NORMSTDEV.PSTDEV.SWORKDAY.INTL。而且,在这种情况下,XOR.

为了让它们起作用,您需要在公式前加上前缀 _xlfn.。像这样:

'criteria': '=_xlfn.XOR(ISERR(FIND("text1",LOWER($F2))),ISERR(FIND("text2",LOWER($F2))))', 

前缀未出现在 Excel 中。

参见following section of the XlsxWriter docs on Working with Formulas