PerlIO::via::csv - PerlIO layer to convert between Excel and CSV
use PerlIO::via::csv sheet => 2; open my $fh, '<:via(csv)', 'file.xls' or die "Can't open file.xls: $!";
This module implements a PerlIO layer that converts a spreadsheet (anything readable by Spreadsheet::Read, like an Excel file) into comma-separated values (CSV) format. It is currently readonly.
The spreadsheet is emulated as a stream of bytes where each cell is a byte. So $line = readline $fh might put 1,2.3,foo into $line. Only one of the sheets in a multi-sheet spreadsheet is read, and sheet numbers start at 1. You can also use sheet names (see "Class methods").
$line = readline $fh
1,2.3,foo
Currently that's about it, so you're probably better off using one of the xsl2csv utilities available elsewhere (see "SEE ALSO"). I hope to support write and append modes (Spreadsheet::ParseExcel::SaveParser?) and filehandle methods like seek and tell. Suggestions welcome.
You can affect which worksheet to read with the sheet class method, which can also be set when you use the module.
sheet
use
Specify which worksheet to read from. The sheet that is set when you open the file will be the one read from. Use it like this:
use PerlIO::via::csv sheet => 3;
or
use PerlIO::via::csv; PerlIO::via::csv->sheet(3);
Tip: try using the name of the worksheet instead of its number (which starts at 1).
If you want to read multiple sheets, set a new sheet before reopening the file.
Note: I was thinking of reading all worksheets by default; not sure if that makes sense, though.
Spreadsheet::Read (and xls2csv in the samples directory)
Spreadsheet::ParseExcel (and xls2csv.pl in the samples directory)
http://search.cpan.org/~ken/xls2csv/script/xls2csv
Text::CSV
Scott Lanning <slanning@cpan.org>.
Copyright 2009, Scott Lanning. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PerlIO::via::csv, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlIO::via::csv
CPAN shell
perl -MCPAN -e shell install PerlIO::via::csv
For more information on module installation, please visit the detailed CPAN module installation guide.