You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用openpyxl的wb.save()时出现Fill() TypeError问题求助

TypeError when calling wb.save() in openpyxl: Fill() takes no arguments

I'm encountering an error when using wb.save() with openpyxl, and I can't figure out what's causing it. The error only occurs under specific execution conditions—my code is meant to format multiple Excel worksheets and export them into the same workbook. I've seen similar error reports before, but all of them were related to the load_workbook() function, not save().

Code that triggers the error:

wb.save(output_filename)

Error messages from the terminal:

File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\descriptors\base.py", line 55, in _convert
    value = expected_type(value)
TypeError: Fill() takes no arguments


During handling of the above exception, another exception occurred:

  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert
    raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'openpyxl.styles.fills.Fill'>

Relevant code block that triggers the TypeError:

def _convert(expected_type, value):
    """
    Check value is of or can be converted to expected type.
    """
    if not isinstance(value, expected_type):
        try:
            value = expected_type(value)
        except:
            raise TypeError('expected ' + str(expected_type))
    return value

Any technical support would be greatly appreciated.

内容的提问来源于stack exchange,提问作者mot375

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 17:47:08