问题
I want to apply format to cells in a column. The row indexes are 5,7,8,9,10,11 and 13.
The code I am using is the following:
worksheet.conditional_format("C4:C14", {'type' : 'formula',
'criteria': '=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE',
'format' : format_white})
The result is no Excel file is generated.
The formula =ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
works as I expected when I type it directly in Excel. I run the code above with a simpler formula 'criteria': '=MOD(ROW(),2)=0'
and it works, so I suspect the problem is in the criteria field.
Can anyone help me? Thanks in advance
回答1:
In order for a formula to work in an XlsxWriter generated file it has to work in Excel.
In this case the conditional formula formula isn't valid in Excel:
=ISNUMBER(MATCH(ROW(),{5,7,8,9,10,11,13},0))=TRUE
If you add it manually in Excel you get the following error/warning:
"You may not use reference operators (such as unions, intersections, and ranges) or other array constants for Conditional Formatting criteria".
来源:https://stackoverflow.com/questions/35338347/xlsxwriter-conditional-formatting-by-formula-criteria