Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/reveng2.xlsx
Binary file not shown.
8 changes: 7 additions & 1 deletion tests/test_open_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ def test_xlsx(self):
# we should make assertions here that data has been
# correctly processed.


def test_err_cell_empty(self):
# For cell with type "e" (error) but without inner 'val' tags
open_workbook(from_this_dir('err_cell_empty.xlsx'))

def test_xlsx_2007_variant(self):
# For now, we just check this doesn't raise an error.
open_workbook(from_this_dir('reveng2.xlsx'))
# we should make assertions here that data has been
# correctly processed.

2 changes: 1 addition & 1 deletion xlrd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def open_workbook(filename=None,
if verbosity:
logfile.write('ZIP component_names:\n')
pprint.pprint(component_names, logfile)
if 'xl/workbook.xml' in component_names:
if 'xl/workbook.xml' in component_names or 'xl/workbook2.xml' in component_names:
from . import xlsx
bk = xlsx.open_workbook_2007_xml(
zf,
Expand Down
12 changes: 10 additions & 2 deletions xlrd/xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,19 @@ def open_workbook_2007_xml(
bk.on_demand = False
bk.ragged_rows = ragged_rows

# We could have one of two sets of file names to open
if 'xl/workbook.xml' in component_names:
extra = ''
elif 'xl/workbook2.xml' in component_names:
extra = '2'
else:
raise XLRDError( 'ZIP file contents unexpected.' )

x12book = X12Book(bk, logfile, verbosity)
zflo = zf.open(component_names['xl/_rels/workbook.xml.rels'])
zflo = zf.open(component_names['xl/_rels/workbook{}.xml.rels'.format(extra)])
x12book.process_rels(zflo)
del zflo
zflo = zf.open(component_names['xl/workbook.xml'])
zflo = zf.open(component_names['xl/workbook{}.xml'.format(extra)])
x12book.process_stream(zflo, 'Workbook')
del zflo
props_name = 'docprops/core.xml'
Expand Down