开发者

How can I read Excel files in Perl?

开发者 https://www.devze.com 2022-12-18 05:39 出处:网络
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).

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开发者_Python百科 it to read rows of data more or less.


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


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


Check out the synopsis in these modules:

  • Spreadsheet::ParseExcel,
  • Spreadsheet::WriteExcel
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号