Error while Converting Excel to CSV using xls2csv

I am using xls2csv to convert a xls file into a regular .csv file. However, while using the command as

xls2csv fromfile.xls > tofile.csv

I am getting the following error.

fromfile.xls is not OLE file or Error

I also tried to specify the comma as delimiter but did not help...

xls2csv -c\, fromfile.xls > tofile.csv

Do not know what is it that I am doing wrong.

Try running against simple testing .xls documents saved form Excel, with both "Excel 97-2003 Workbook" and "Microsoft Excel 5.0/95 Workbook" formats.

There are a few different versions of xls2csv around, including a CPAN perl module. Please paste any output you get from xls2csv -V here so we know what we are dealing with.

@Chubler_XL: The xls2csv version is "Catdoc Version 0.94.2". I will check against simple .xls and let you know tomorrow as I do not have access at home...

hi,

more probably, your .xls file is not an xls file.
what does answer ``file yourFile.xls'' ?

I've already downloaded files as .xls which were in fact html ones.

I've done some quick tests here with that version and both "Excel 97-2003 Workbook" and "Microsoft Excel 5.0/95 Workbook" formats convert fine.

However if I save as "XML workbook format", which has a default extension of xml by the way. I also get the same error:

$ ls ss*
ss_95.xls  ss_97.xls  ss.xml

$ file ss*
ss_95.xls: Composite Document File V2 Document, Little Endian, Os: Windows, Version 6.1, Code page: 1252, Author: Chubler_XL, Last Saved By: Chubler_XL, Name of Creating Application: Microsoft Excel, Create Time/Date: Mon Nov 18 02:31:35 2013, Last Saved Time/Date: Mon Nov 18 02:32:49 2013, Security: 0
ss_97.xls: Composite Document File V2 Document, Little Endian, Os: Windows, Version 6.1, Code page: 1252, Author: Chubler_XL, Last Saved By: Chubler_XL, Name of Creating Application: Microsoft Excel, Create Time/Date: Mon Nov 18 02:31:35 2013, Last Saved Time/Date: Mon Nov 18 02:32:33 2013, Security: 0
ss.xml:    XML document text

$ xls2csv ss_95.xls 
"Name","age","ss"
"Tim","16","10"
"Mike","45","11"
"Steve","28","12"

$ xls2csv ss.xml
ss.xml is not OLE file or Error

So it looks like the OLE error indicates an unsupported XLS format or a corrupted file.

@dePeach/@Chubler_XL: Sorry for the late reply,

file fromfile.xls

gives me

fromfile.xls: data

So, I assume this file that I am working on is not really a .xls file. How do I work in converting this file into .CSV file? Appreciate your help.

This first stage is going to be finding out what format the file is in. Transfer the file to a windows box and try opening it with Excel.

If Excel can open it try SaveAs, using "Excel 97-2003 Workbook" or "Microsoft Excel 5.0/95 Workbook" format and test the newly saved file with xls2csv. If this works then we have proven that the format of the original .xls, although recognisable by Excel, is not supported by xls2csv.

If Excel won't open it you have little options -> the file is corrupted, rebuild/resave a proper .xls file.

Excel is likely to save it as whatever it was in the first place, which is why you keep getting xml. Move your originals to xls and it'll try to keep saving them as xls.

Excel confuses this by calling everything xls. anything from xml, csv, to an actual xls file can be saved under the xls extension sometimes.