【发布时间】:2020-06-29 21:19:08
【问题描述】:
我想从 Excel 表中读取背景颜色。我正在用openpyxl尝试这个,但是当我尝试加载文件时
openpyxl.load_workbook("myfile.xlsx", data_only=True)
我收到以下错误:
Traceback (most recent call last):
File "\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:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "\openpyxl\reader\excel.py", line 315, in load_workbook
reader.read()
File "\openpyxl\reader\excel.py", line 279, in read
apply_stylesheet(self.archive, self.wb)
File "\openpyxl\styles\stylesheet.py", line 192, in apply_stylesheet
stylesheet = Stylesheet.from_tree(node)
File "\openpyxl\styles\stylesheet.py", line 102, in from_tree
return super(Stylesheet, cls).from_tree(node)
File "\openpyxl\descriptors\serialisable.py", line 103, in from_tree
return cls(**attrib)
File "\openpyxl\styles\stylesheet.py", line 73, in __init__
self.fills = fills
File "\openpyxl\descriptors\sequence.py", line 26, in __set__
seq = [_convert(self.expected_type, value) for value in seq]
File "\openpyxl\descriptors\sequence.py", line 26, in <listcomp>
seq = [_convert(self.expected_type, value) for value in seq]
File "\openpyxl\descriptors\base.py", line 57, in _convert
raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'openpyxl.styles.fills.Fill'>
我可以做些什么来获得这个问题并像这里一样阅读 bg 颜色:Get cell color from .xlsx ?
【问题讨论】:
-
您的 XLSX 文件中可能存在错误。