xlsx saved as xls in libreoffice gives error in xlrd

456 views
Skip to first unread message

python...@raf.org

unread,
Oct 26, 2014, 9:00:58 PM10/26/14
to python...@googlegroups.com
macosx-10.6.8, python-2.7.8, xlrd-0.9.3

hi,

i received an xlsx file that i need xlrd to read (with formatting_info=True
so i can tell how many digits are displayed for numbers) so i saved it using
libreoffice-4.3.2.2 as xls and then xlrd gave this error:

Traceback (most recent call last):
File "lib/xls.py", line 129, in reader
book = xlrd.open_workbook(fname, formatting_info=True, logfile=_devnull)
File "[...]/python2.7/site-packages/xlrd/__init__.py", line 435, in open_workbook
ragged_rows=ragged_rows,
File "[...]/python2.7/site-packages/xlrd/book.py", line 119, in open_workbook_xls
bk.get_sheets()
File "[...]/python2.7/site-packages/xlrd/book.py", line 678, in get_sheets
self.get_sheet(sheetno)
File "[...]/python2.7/site-packages/xlrd/book.py", line 669, in get_sheet
sh.read(self)
File "[...]/python2.7/site-packages/xlrd/sheet.py", line 1079, in read
saved_obj = self.handle_obj(data)
File "[...]/python2.7/site-packages/xlrd/sheet.py", line 1893, in handle_obj
raise XLRDError(msg)
XLRDError: Unexpected data at end of OBJECT record

however, if i use openoffice-4.0.1 to save it as an xls, then xlrd can read
it without error.

any idea what's wrong?

i've just started using libreoffice by default because openoffice no longer
supports my old version of macosx.

cheers,
raf

Adrian Klaver

unread,
Oct 26, 2014, 9:58:17 PM10/26/14
to python...@googlegroups.com
Well the first thing that comes to mind is that your LibreOffice and OO
instances are saving different year versions of xls.

Have you checked exactly what LibreOffice is saving versus OpenOffice?

>
> i've just started using libreoffice by default because openoffice no longer
> supports my old version of macosx.
>
> cheers,
> raf
>


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

python...@raf.org

unread,
Oct 26, 2014, 10:31:13 PM10/26/14
to python...@googlegroups.com
OpenOffice says: Microsoft Excel 97/2000/XP (.xls)
LibreOffice says: Microsoft Excel 97/2000/XP/2003 (.xls)

if they're different then that would mean that the 2003 format
isn't the same as the 97/2000/XP format but if that were the
case why call two different formats the 97/2000/XP/2003 format? (rhetorical)

but obviously they must be different. file says:

OpenOffice version:
Composite Document File V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Revision Number: 0
LibreOffice version:
Composite Document File V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Revision Number: 1

so there's a different revision number.

are there any plans for xlrd to support revision 1 / 2003xls / libreoffice ?

i guess i can't get rid of openoffice yet.

cheers,
raf

Adrian Klaver

unread,
Oct 26, 2014, 10:48:19 PM10/26/14
to python...@googlegroups.com
I have not used it, but you might to take a look at:

https://openpyxl.readthedocs.org/en/latest/

python...@raf.org

unread,
Nov 10, 2014, 12:15:38 AM11/10/14
to python...@googlegroups.com
i'd prefer it if xlrd could read xls files created by libreoffice.
is that likely to happen?

cheers,
raf

Adrian Klaver

unread,
Nov 11, 2014, 9:41:47 AM11/11/14
to python...@googlegroups.com
Not sure, but it might help to file an issue here:

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

python...@raf.org

unread,
Nov 16, 2014, 5:25:16 PM11/16/14
to python...@googlegroups.com
it seems that not all xls spreadsheets created by libreoffice are a problem.
if i can create a problematic spreadsheet without sensitive data in it, i'll
file an issue. maybe the stack trace will be enough by itself but probably not.

Ghislain Leveque

unread,
Dec 23, 2014, 10:11:04 AM12/23/14
to python...@googlegroups.com, python...@raf.org
I have an xls file that cause the same problem, I will file an issue
Reply all
Reply to author
Forward
0 new messages