→ Converting Excel XLS to CSV files using Command Line in Unix/Linux → → →

How many times did I have this problem throughout my working life? Way too many. Not only me, almost every other developer I know. There's an easy way out though, let's dive straight into it.

Our solution is going to be xls2csv library, a part of CPAN project. (http://search.cpan.org/)

This means you'll have to have Perl installed on your machine, but don't worry, you don't have to know any of Perl.

Let's start with dowloading xls2csv, which you can find here: version 1.06

Use wget, curl or any other tool of choice to get it, and then extract the archive (tar -zxf FILENAME).


You're going to use Perl's shell at the initial phase of installation instead of normal one. Without it, it's very like you'll get error like: "Warning: prerequisite Locale::Recode 0 not found." while trying to install xls2csv. Let's start the shell first:

perl -MCPAN -e 'shell'

Then simply follow all steps below:

install CPAN
reload CPAN
install YAML
install Locale::Recode
install Unicode::Map
install Spreadsheet::ParseExcel
install Spreadsheet::ParseExcel::FmtUnicode
install Text::CSV_XS

If everything was properly installed, you can get to installing xls2csv itself. Short procedure is described in README, but to make it easier, I'll put it down here as well:

perl Makefile.PL
make test
make install

That's about it. You can now convert Excel's XLS files to CSV files with one command line call:

  xls2csv -x XLSfile -c CSVfile

Simple. Enjoy!

Created on 05 November 2010