unable to read from workbook with [invalid] external link
Created originally on Bitbucket by Kirill Marchuk
Hi all
Windows 10, openpyxl 2.3.2
I've got an Excel .xlsx file from our VoIP provider, and I cannot parse it using pyexcel-xlsx due to this exception:
File "C:\Python27\lib\site-packages\openpyxl\workbook\names\external.py", line 83, in parse_ranges names = book.find('{%s}definedNames' % SHEET_MAIN_NS) AttributeError: 'NoneType' object has no attribute 'find'
This is a place where it happens:
#!python
def parse_ranges(xml):
tree = fromstring(xml)
book = tree.find('{%s}externalBook' % SHEET_MAIN_NS)
names = book.find('{%s}definedNames' % SHEET_MAIN_NS)
the "xml" parameter is as follows:
apparently, there's not "externalBook" element, so book is set to None and this condition is not checked in the code
Would you say it's a bug or just faulty Workbook ? It works in Excel, otherwise, with a warning about invalid external links. If I remove links from file, it's processed fine with openpyxl
Attachments: your_data_wrong_empty.xlsx