http://www.perlmonks.org?node_id=646329

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

Hello monks,

I'm about to start a small consulting job with a company that needs ~400 excel documents parsed. Rather than spend my time opening each document and manually saving it as "text", I've heard of Excel modules such as Spreadsheet-ParseExcel but I know little about how well they work. I'd like a module that is popular with the Perl community and one that is actively being maintained. If it makes a difference, I do most of my Perl scripting on Cygwin. Any suggestions?

Thank you

Replies are listed 'Best First'.
Re: What is the best module for parsing Excel documents
by erroneousBollock (Curate) on Oct 22, 2007 at 00:13 UTC
    Spreadsheet::ParseExcel does what you want, but if you simply want to avoid manually opening excel to do the CSV exports, use Win32::OLE to automate the process.

    -David

Re: What is the best module for parsing Excel documents
by Gangabass (Vicar) on Oct 22, 2007 at 02:09 UTC
Re: What is the best module for parsing Excel documents
by roboticus (Chancellor) on Oct 22, 2007 at 02:15 UTC
    I've used Spreadsheet::ParseExcel, and really like it. However, I tend to stick to the plain vanilla features, so I don't know if it's suitable for what you want. If you're just wanting to read a bunch of data out of spreadsheets, it's probably the right choice.

    ...roboticus

Re: What is the best module for parsing Excel documents
by strat (Canon) on Oct 22, 2007 at 08:50 UTC

    If you have Win32::OLE installed (I don't know if this is possible under Cygwin), you could have a look at ExcelPerl, e.g. convert the file to csv with something like:

    perl excelPerl.pl -begin "use Text::CSV_XS; $csv = Text::CSV_XS->new( +{ binary => 1 } )" -ane "$csv->combine(@F); print $csv->string, $/" - +f test.xls > outfile.csv

    Or if you want to keep the formulas:

    perl excelPerl.pl -begin "use Text::CSV_XS; $csv = Text::CSV_XS->new( +{ binary => 1 } )" -ane "$csv->combine( map { $_->{FormulaLocal} } @C +); print $csv->string, $/" -f test.xls > outfile.csv

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"