perlbond has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am newbie to Perl. I need help with following,

I need to write a tool on UNIX using Perl that reads 2 Excel workbooks. It should read a row of data from the
first workbook and extract data from each column of that row. Then it needs to search for data from two of
the columns in that row in another excel workbook. If it finds a match, then it should generate a command
based on all the extracted column values and write it into a new text file.

I don't know how to open and read data from excel workbook. If there are more then one spreadsheets in the workbook, how to read data from each sheet at a time?

I would really appreciate all the help I can get.

Thanks.

Replies are listed 'Best First'.
Re: Parsing Excel Workbook
by Errto (Vicar) on May 26, 2004 at 03:15 UTC
    I've never used it (though I anticipate doing so soon), but it appears that Spreadsheet::ParseExcel is capable of doing that. It seems a bit complex, so perhaps if you're new to Perl Spreadsheet::ParseExcel::Simple may be a better choice. Ask me in a week or so what I think of them, as I'll be starting a project that may involve their use. If you're not familiar with how to install modules from CPAN, there is a nice FAQ on CPAN's main site, and a PerlMonks Tutorial here.
      I love Spreadsheet::ParseExcel::Simple. Its incredibly easy to use, and I think the interface is much more intuitive and obvious that that of Spreadsheet::ParseExcel. here's a snippet of code that I use:
      my $xls = Spreadsheet::ParseExcel::Simple->read($excel); #$excel is a +filehandle. warn "read Excel spreadsheet"; #warn Dumper $xls; my @data; foreach my $sheet ($xls->sheets) { while ($sheet->has_data) { push @row, $sheet->next_row; } }
Re: Parsing Excel Workbook
by dragonchild (Archbishop) on May 26, 2004 at 13:13 UTC
    Spreadsheet::ParseExcel is the tool you want. The interface is a little wonky, but it's the only module on Unix that will do what you want.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested