xlsxwriter 按公式标准条件格式化
xlsxwriter conditional formatting by formula criteria
我想对列中的单元格应用格式。行索引为 5、7、8、9、10、11 和 13。
我使用的代码如下:
worksheet.conditional_format("C4:C14", {'type' : 'formula',
'criteria': '=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE',
'format' : format_white})
结果没有Excel文件生成。
当我直接在 Excel 中输入时,公式 =ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
的效果与我预期的一样。我 运行 上面的代码有一个更简单的公式 'criteria': '=MOD(ROW(),2)=0'
并且它有效,所以我怀疑问题出在条件字段中。
谁能帮帮我?提前致谢
为了使公式在 XlsxWriter 生成的文件中起作用,它必须在 Excel.
中起作用
在这种情况下,条件公式公式在 Excel 中无效:
=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
如果您在 Excel 中手动添加它,您会得到以下结果 error/warning:
"You may not use reference operators (such as unions, intersections, and ranges) or other array constants for Conditional Formatting criteria".
我想对列中的单元格应用格式。行索引为 5、7、8、9、10、11 和 13。
我使用的代码如下:
worksheet.conditional_format("C4:C14", {'type' : 'formula',
'criteria': '=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE',
'format' : format_white})
结果没有Excel文件生成。
当我直接在 Excel 中输入时,公式 =ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
的效果与我预期的一样。我 运行 上面的代码有一个更简单的公式 'criteria': '=MOD(ROW(),2)=0'
并且它有效,所以我怀疑问题出在条件字段中。
谁能帮帮我?提前致谢
为了使公式在 XlsxWriter 生成的文件中起作用,它必须在 Excel.
中起作用在这种情况下,条件公式公式在 Excel 中无效:
=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
如果您在 Excel 中手动添加它,您会得到以下结果 error/warning:
"You may not use reference operators (such as unions, intersections, and ranges) or other array constants for Conditional Formatting criteria".