Cannot read XLSX with bare styles.xml

Issue #553 duplicate
whitehat2k13 NA created an issue

See attached file and trace:

In [1]: import openpyxl

In [2]: wbr = openpyxl.reader.excel.load_workbook(filename='no_style.xlsx', use_iterators=True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-f9829bd0c00c> in <module>()
----> 1 wbr = openpyxl.reader.excel.load_workbook(filename='no_style.xlsx', use_iterators=True)

/usr/local/lib/python2.7/dist-packages/openpyxl/reader/excel.pyc in load_workbook(filename, read_only, use_iterators, keep_vba, guess_types, data_only)
    200         assert wb.loaded_theme == None, "even though the theme information is missing there is a theme object ?"
    201 
--> 202     parsed_styles = read_style_table(archive)
    203     if parsed_styles is not None:
    204         wb._differential_styles = parsed_styles.differential_styles

/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.pyc in read_style_table(archive)
    179         xml_source = archive.read(ARC_STYLE)
    180         p = SharedStylesParser(xml_source)
--> 181         p.parse()
    182         return p
    183 

/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.pyc in parse(self)
     51         self.parse_dxfs()
     52         self.parse_cell_styles()
---> 53         self.parse_named_styles()
     54 
     55 

/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.pyc in parse_named_styles(self)
    107         styles = self._parse_xfs(node)
    108 
--> 109         names = self._parse_style_names()
    110         for style in names.values():
    111             _id = styles[style.xfId]

/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.pyc in _parse_style_names(self)
    126         node = self.root.find("{%s}cellStyles" % SHEET_MAIN_NS)
    127         names = {}
--> 128         for _name in node:
    129             name = _name.get("name")
    130             style = NamedStyle(name=name,

TypeError: 'NoneType' object is not iterable

Comments (3)

  1. Log in to comment