How can I read Excel files in Perl?

23,391

Solution 1

The Spreadsheet::ParseExcel module can read Excel files. The documentation includes examples how to use it.

Solution 2

You can use Spreadsheet::Read which will delegate to the appropriate module to read spreadsheets in a variety of formats such as Excel, OpenOffice and CSV.

On the other hand, given your problem description, I think you would be much better off using a standard configuration file format:

#!/usr/bin/perl

use Config::Std;

read_config 'ftp.ini' => my %config;

for my $file ( keys %config ) {
    print "File: '$file'\n";
    print "$_: ", $config{$file}->{$_}, "\n"
        for qw( site protocol remote_name);
}

ftp.ini:

[c:\Documents and Settings\user\My Documents\this.txt]
site = ftp.example.com
protocol = ftp
remote_name = that.txt

Solution 3

Check out the synopsis in these modules:

Share:
23,391
James
Author by

James

Updated on April 06, 2020

Comments

  • James
    James about 4 years

    I am looking for some examples/advice on how to write a Perl script to read data from an excel file then use the data read in (as a string hopefully) and pass it to another Perl file (as an argument).

    The goal is to have a table in which the user can type some data (ftp destination or filename) into the table. Then my program will grab that data at do some automation with it. It does not have to be very elegant in implementation ... Just need it to read rows of data more or less.