Xls2csv

From Christoph's Personal Wiki
Revision as of 04:58, 11 March 2007 by Christoph (Talk | contribs)

Jump to: navigation, search
The correct title of this article is xls2csv. The initial letter is capitalized due to technical restrictions.

xls2csv is a command line script that recodes a spreadsheet's charset and saves as CSV. It was written by Ken Prows.

Install

perl -MCPAN -e "install Locale::Recode"
perl -MCPAN -e "install Unicode::Map"
perl -MCPAN -e "install Spreadsheet::ParseExcel"
perl -MCPAN -e "install Spreadsheet::ParseExcel::FmtUnicode" (should be included with Spreadsheet::ParseExcel)
perl -MCPAN -e "install Text::CSV_XS"
wget http://search.cpan.org/CPAN/authors/id/K/KE/KEN/xls2csv-1.06.tar.gz

Basic usage

The following example will convert a spreadsheet that is in the WINDOWS-1252 character set (WinLatin1) and save it as a csv file in the UTF-8 character set.

xls2csv -x "1252spreadsheet.xls" -b WINDOWS-1252 -c "ut8csvfile.csv" -a UTF-8

This example with convert the worksheet named "Users" in the given spreadsheet.

xls2csv -x "multi_worksheet_spreadsheet.xls" -w "Users" -c "users.csv" 

Options

-x     : filename of the source spreadsheet
-b     : the character set the source spreadsheet is in (before)
-c     : the filename to save the generated csv file as
-a     : the character set the csv file should be converted to (after)
-q     : quiet mode
-s     : print a list of supported character sets
-h     : print help message
-v     : get version information
-W     : list worksheets in the spreadsheet specified by -x
-w     : specify the worksheet name to convert (defaults to the first worksheet)

See also

External links