Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
工作表单元格格式不工作-Python_Python_Excel_Format_Openpyxl - Fatal编程技术网

工作表单元格格式不工作-Python

工作表单元格格式不工作-Python,python,excel,format,openpyxl,Python,Excel,Format,Openpyxl,我尝试使用下面的代码格式化工作表, 如果文本在“列G”中包含“未知”,我想使用openpyxl red_fill = PatternFill(bgColor="FFC7CE") dxf = DifferentialStyle(fill=red_fill) rule = Rule(type="containsText", operator="containsText", text="unknown", dxf=dxf) rule.formula = ['NOT(IS

我尝试使用下面的代码格式化工作表, 如果文本在“
列G
”中包含“未知”,我想使用
openpyxl

    red_fill = PatternFill(bgColor="FFC7CE")
    dxf = DifferentialStyle(fill=red_fill)
    rule = Rule(type="containsText", operator="containsText", text="unknown", dxf=dxf)
    rule.formula = ['NOT(ISERROR(SEARCH("unknown")))']
    workingsheet.conditional_formatting.add('G1:G100', rule)
但是,不起作用

编辑:

请参阅输入和预期输出


请粘贴完整的代码。您要导入哪些库?我想使用“openpyxl”。我想“完整代码”指的是一个完整但最小的示例。我无法复制您的示例。这真的是你的全部代码吗??