BUG: XLS files saved by Excel 2013 on Windows cause AssertionError

562 views
Skip to first unread message

Dr.Irv

unread,
Oct 14, 2015, 8:44:22 PM10/14/15
to python-excel
I was doing some testing of pandas and saved the same file as an XLSX and an XLS file for unit testing.  On Windows, I use Excel 2013. I need the XLS file to test Pandas.

Here is the bug in xlrd 0.9.3 that I found.  I start with an XLSX file on Windows with Excel 2013.  That is attached as xlrdtest.xlsx.  That file reads fine with xlrd.
I then use Excel 2013 to save the file as an XLS file (so that I can test it with pandas unit testing).  That file is attached as xlrdtest.xls .  That file fails to read in with xlrd:

>>> wk = xlrd.open_workbook("xlrdtest.xls")
*** formula/tFunc unknown FuncID:186
*** formula/tFunc unknown FuncID:186
*** formula/tFunc unknown FuncID:186
*** formula/tFunc unknown FuncID:186
*** formula/tFunc unknown FuncID:186
*** formula/tFunc unknown FuncID:186
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-16-eb22c9b75a70>", line 1, in <module>
    wk = xlrd.open_workbook("xlrdtest.xls")
  File "C:\Anaconda3\lib\site-packages\xlrd\__init__.py", line 435, in open_workbook
    ragged_rows=ragged_rows,
  File "C:\Anaconda3\lib\site-packages\xlrd\book.py", line 116, in open_workbook_xls
    bk.parse_globals()
  File "C:\Anaconda3\lib\site-packages\xlrd\book.py", line 1198, in parse_globals
    self.names_epilogue()
  File "C:\Anaconda3\lib\site-packages\xlrd\book.py", line 997, in names_epilogue
    evaluate_name_formula(self, nobj, namex, blah=blah)
  File "C:\Anaconda3\lib\site-packages\xlrd\formula.py", line 1125, in evaluate_name_formula
    assert len(tgtobj.stack) == 1
AssertionError

I then transfer the XLSX file xlrdtest.xlsx to a Mac, and use Excel Mac 2011 to read in that file and save it as an XLS file.  That is attached as xlrdtestMac.xls.  That file reads in fine with xlrd.

So it seems the problem is with how the Windows version of Excel is saving the file.

Note that it is the presence of multiple worksheets that seems to trigger the exception.  If the original XLSX file has one sheet, then the Excel 2013 saved XLS file reads in fine.

xlrdtestMac.xls
xlrdtest.xls
xlrdtest.xlsx

Adrian Klaver

unread,
Oct 14, 2015, 9:52:47 PM10/14/15
to python...@googlegroups.com
So are the formulas in the multiple worksheet case linked across sheets?



--
Adrian Klaver
adrian...@aklaver.com

Dr.Irv

unread,
Oct 15, 2015, 10:14:43 AM10/15/15
to python-excel
There are no formulas in the example I provided.

Adrian Klaver

unread,
Oct 15, 2015, 10:50:35 AM10/15/15
to python...@googlegroups.com
On 10/15/2015 07:14 AM, Dr.Irv wrote:
> There are no formulas in the example I provided.

Hmm.

I used the latest clone from the repo:

https://github.com/python-excel/xlrd/tree/master/xlrd

which contains some fixes for reading sheet names and that did not help.
I got the same error. FYI the Mac version worked for me also. This is on
openSUSE 13.1 with Python 2.7.

I would say file an issue:

https://github.com/python-excel/xlrd/issues
> adrian...@aklaver.com <javascript:>
>
> --
> You received this message because you are subscribed to the Google
> Groups "python-excel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to python-excel...@googlegroups.com
> <mailto:python-excel...@googlegroups.com>.
> To post to this group, send email to python...@googlegroups.com
> <mailto:python...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/python-excel.
> For more options, visit https://groups.google.com/d/optout.


--
Adrian Klaver
adrian...@aklaver.com

Dr.Irv

unread,
Oct 15, 2015, 10:59:31 AM10/15/15
to python-excel
Thanks for reproducing it.  I have created an issue as  you suggested.
Reply all
Reply to author
Forward
0 new messages