What's the simplest way to parse an Excel file in Perl? Converting it to a text file would also work.
I've good luck with the Ruby port of it as well
Matt Ephraim
2009-01-09 18:41:39
+3
A:
The 'best' way would ideally be to use a module from our beloved CPAN.
Whenever you have a problem Instantly ask: Why have I not checked CPAN yet?
Which module however I can't be certain, here is a list to get you started, try them, see what works.
Kent Fredric
2009-01-09 18:43:10
+12
A:
The best way is to use Spreadhsheet::ParseExcel.
Here is an example:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->Parse('Book1.xls');
for my $worksheet ( $workbook->worksheets() ) {
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
for my $row ( $row_min .. $row_max ) {
for my $col ( $col_min .. $col_max ) {
my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;
print "Row, Col = ($row, $col)\n";
print "Value = ", $cell->value(), "\n";
print "Unformatted = ", $cell->unformatted(), "\n";
print "\n";
}
}
}
To convert an Excel file to text with Perl I'd recommend excel2txt which uses Spreadsheet::ParseExcel.
jmcnamara
2009-01-09 20:01:48