tags:

views:

489

answers:

3

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.

+5  A: 

Check out the synopsis in these modules:

Evan Carroll
Or he could just have Excel spreadsheets as .csv (or similar) and save himself a lot of trouble :D
dangerstat
That is a very valid point, CSVs are *a lot* easier to create and manipulate, and work with if you using them is permitted, it is certainly the way to go. Use Text::CSV_XS, and set always_quote=>1, and it will work great with excel.
Evan Carroll
+8  A: 

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

Lukáš Lalinský
+3  A: 

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
Sinan Ünür
It's probably a lot easier and safer to get Joe Random User to type something into Excel cells than to get them editing a text file with a structure most of them will never have seen. Plus you could do all sorts of validation and input checking with macros/etc. in the Excel file that you can't with .ini files.
rjp