NAME

PerlIO::via::csv - PerlIO layer to convert between Excel and CSV

SYNOPSIS

use PerlIO::via::csv sheet => 2;
open my $fh, '<:via(csv)', 'file.xls'
  or die "Can't open file.xls: $!";

DESCRIPTION

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").

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.

INTERFACE

You can affect which worksheet to read with the sheet class method, which can also be set when you use the module.

Class methods

sheet

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.

TODO

Dates are broken. Not sure if that's my problem or Tux's.
There are probably problems with encoding.
Not sure I like how sheets are handled.
Other I/O operations like seek, tell, unread.
Writing files.

SEE ALSO

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

AUTHORS

Scott Lanning <slanning@cpan.org>.

LICENSE

Copyright 2009, Scott Lanning. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.