List index error while loading the .xlsx file

512 views
Skip to first unread message

anantnar...@gmail.com

unread,
May 25, 2019, 5:16:59 AM5/25/19
to openpyxl-users
I wanted to load a file but I found errors. load_workbook is working for most of the files but not this one

import openpyxl as opx
import os
di = os.getcwd()
wb = opx.load_workbook(di+'\\WMT-Fletcher.xlsx')

Traceback (most recent call last):
File "F:/Pycharm Projects/asd2.py", line 4, in <module>
wb = opx.load_workbook(di+'\\WMT-Fletcher.xlsx')
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\reader\excel.py", line 312, in load_workbook
reader.read()
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\reader\excel.py", line 273, in read
apply_stylesheet(self.archive, self.wb)
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 189, in apply_stylesheet
stylesheet = Stylesheet.from_tree(node)
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 103, in from_tree
return super(Stylesheet, cls).from_tree(node)
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\descriptors\serialisable.py", line 104, in from_tree
return cls(**attrib)
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 94, in __init__
self.named_styles = self._merge_named_styles()
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 114, in _merge_named_styles
self._expand_named_style(style)
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\stylesheet.py", line 124, in _expand_named_style
xf = self.cellStyleXfs[named_style.xfId]
File "F:\Pycharm Projects\venv\lib\site-packages\openpyxl\styles\cell_style.py", line 186, in __getitem__
return self.xf[idx]
IndexError: list index out of range


WMT-Fletcher.xlsx

Charlie Clark

unread,
May 27, 2019, 5:21:41 AM5/27/19
to openpyx...@googlegroups.com
Am .05.2019, 11:16 Uhr, schrieb <anantnar...@gmail.com>:

> I wanted to load a file but I found errors. load_workbook is working for
> most of the files but not this one.

That's because the file is broken: the cells contains links to style
definitions but no stylesheet.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Reply all
Reply to author
Forward
0 new messages