XLSperl
view release on metacpan or search on metacpan
bin/XLSperl view on Meta::CPAN
splitting on whitespace)
=item -l
Automated line-end processing - chomps the value of each cell and sets
$/ to "\n"
=item -p
Prints the value of $_ after each iteration of the input loop
=item -e <perl_code>
Perl code to execute on each iteration of the input loop (required)
=item -m
=item -M
The C<-m> and C<-M> options load additional modules into XLSperl in the
same way as the C<-m> and C<-M> options to C<perl> (see L<http://perldoc.perl.org/perlrun.html>.
=item -w
Enables warnings
=item -v
Prints version number and exits
=back
=head2 Special variables
XLSperl adds the following special varables:
=over
=item $WS
Worksheet name
=item $ROW
Current row (1 .. x)
=item $COL
Current column name (A .. x)
=item $COLNUM
Current column number (1 .. x)
=item $CELL
Current cell (A1 .. ZZx)
=item @F
Array of cell values (in autosplit mode)
=item %F
Hash of cell values (in autosplit mode). Entries in %F are aliases
for the corresponding elements of @F, so modifying $F{A} will also
update the value of $F[0] and vice-versa.
=back
=head2 Exported functions
XLSperl adds the following new functions for use in your Perl code:
=over
=item XLSprint( cell_1, cell_2, ... cell_X );
Outputs a row of data in Excel format. Usage is as follows:
# Print row to default filehandle
XLSprint @F;
# Print row to named filehandle
XLSprint STDERR @F;
XLSprint $fh,@F;
Note that once a filehandle has been used with the XLSprint function,
to avoid corruption of the generated Excel file the 'normal' print
function should not be used on that filehandle, i.e. do not do this:
XLSprint STDERR @errors;
warn "An error happened";
=back
=head2 Examples
=over
=item Use a regular expression to extract data from a spreadsheet
XLSperl -nle "/[A-Z](\d+)\d/ and print $1" cells.xls
=item Basic conversion from XLS to CSV
XLSperl -nale 'print join ",",@F' file.xls >file.csv
=item More correct conversion from XLS to CSV (thanks to Sam Vilain):
XLSperl -MText::CSV_XS -nale 'BEGIN{$c=Text::CSV_XS->new} if ($w ne $WS){open CSV,">$ARGV.$WS.csv" or die $!;$w = $WS} $c->print(\*CSV,\@F)' file1.xls file2.xls
=item Extract a single row from a spreadsheet
cat file1.xls | XLSperl -nle 'print if ($ROW == 2)'
=item Convert a text file to Excel format, removing comment lines
XLSperl -F: -nale 'next if /^#/; XLSprint @F' /etc/passwd >passwd.xls
=back
=head1 SYSTEM REQUIREMENTS
XLSperl binary packages have no external dependencies, and have been tested on
( run in 1.175 second using v1.01-cache-2.11-cpan-71847e10f99 )