Failure to read an excel file when CellStyle attribs contain extra fields non-existent in CellStyle class
I get an exception opening an excel file which opens normally with Microsoft Excel app.
Please find below is the stacktrace, I managed to fix the issue with a workaround but wanted to push a PR containing the proper fix If I'm guided about what's exactly wrong.
These are the few lines I've added to L#102:
keys_to_delete = []
for key in attrib:
if key not in dir(cls):
keys_to_delete.append(key)
for key in keys_to_delete:
del attrib[key]
What I understood is that there are missing fields in the class while the attrib argument contains it in cls(**attrib)
located at https://foss.heptapod.net/openpyxl/openpyxl/-/blob/branch/3.1/openpyxl/descriptors/serialisable.py#L103
Traceback (most recent call last):
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/reader/excel.py", line 299, in read
apply_stylesheet(self.archive, self.wb)
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/styles/stylesheet.py", line 198, in apply_stylesheet
stylesheet = Stylesheet.from_tree(node)
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/styles/stylesheet.py", line 103, in from_tree
return super(Stylesheet, cls).from_tree(node)
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/descriptors/serialisable.py", line 87, in from_tree
obj = desc.expected_type.from_tree(el)
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/descriptors/serialisable.py", line 87, in from_tree
obj = desc.expected_type.from_tree(el)
File "/Users/jahan/projects/alpha-energy/excel_read/env2/lib/python3.9/site-packages/openpyxl/descriptors/serialisable.py", line 104, in from_tree
return cls(**attrib)
TypeError: __init__() got an unexpected keyword argument 'id'
Might be related to #1796