Fails to load tableStyleElement without a dxfId

Issue #902 resolved
Carli
created an issue

Excel 2010 creates a TableStyleElement with no dxfId Elment but an size element (see example attached), if you configure "Stripe Size" to 2 (or more) It will only contain a size tag: <tableStyleElement type="secondRowStripe" size="2"/>

Openpyxl fails to load this file as it can't convert the not existing dxfId ("None") to int.

Expected behavior: warn about the not existing dxfId element but still load the file.

Tracelog: File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/00068549/Documents/Pyhton/openpyxl_test.py", line 14, in <module> with xl.load_workbook(Testfile,read_only=True,data_only=True) as wb:

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 221, in load_workbook apply_stylesheet(archive, wb) # bind styles to workbook

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py", line 183, in apply_stylesheet stylesheet = Stylesheet.from_tree(node)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py", line 99, in from_tree return super(Stylesheet, cls).from_tree(node)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 80, in from_tree obj = desc.expected_type.from_tree(el)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 80, in from_tree obj = desc.expected_type.from_tree(el)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 80, in from_tree obj = desc.expected_type.from_tree(el)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 93, in from_tree return cls(**attrib)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\styles\table.py", line 37, in init self.dxfId = dxfId

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py", line 69, in set value = _convert(self.expected_type, value)

File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert raise TypeError('expected ' + str(expected_type))

TypeError: expected <class 'int'>

Comments (1)

  1. Log in to comment