使用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
相关产品推荐
相关产品推荐

