Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Accessing values in a XSL file.

by jmcnamara (Monsignor)
on Oct 27, 2010 at 17:33 UTC ( [id://867800]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Accessing values in a XSL file.
in thread Accessing values in a XSL file.

I maintain Spreadsheet::ParseExcel.

There aren't any column names in an Excel file so you can't use column names to access any data.

--
John.

Replies are listed 'Best First'.
Re^4: Accessing values in a XSL file.
by Anonymous Monk on Oct 27, 2010 at 17:46 UTC
    I came across this example here, it should be what I am looking for.
    #!/usr/bin/perl -w use strict; use warnings; use Spreadsheet::ParseExcel; my $file = "test.xls"; use vars qw($user_name $user_number $identification); my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($file)or die " +Unable to open $file\n"; foreach my $page (@{$workbook->{Worksheet}}) { print "Page $page\n"; if ((defined $page->{MinCol}) && (defined $page->{MaxCol})) { foreach my $col ($page->{MinCol} .. $page->{MaxCol}) { if ($page->{Cells}[0][$col]->{Val} eq "User Name") { $user_name = $col; print "$user_name\n"; } if ($page->{Cells}[0][$col]->{Val} eq "User Number") { $user_number = $col; print "$user_number\n"; } if ($page->{Cells}[0][$col]->{Val} eq "Identification") { $identification = $col; print "$identification\n"; } } } if ((defined $page->{MinRow}) && (defined $page->{MaxRow})) { foreach my $row ($page->{MinRow}+1 .. $page->{MaxRow}) { my $got_user_name = $page->{Cells}[$row][$user_name]->{Val +}; my $got_user_number = $page->{Cells}[$row][$user_number]-> +{Val}; my $got_identification = $page->{Cells}[$row][$identificat +ion]->{Val}; print "\n This will be inserted into the database: $got_us +er_name\n$got_user_number\n$got_identification\n"; } } } exit;

    Any ideas, but it looks good to me!
        Other than this line print "Page $page\n";, there is no need for it, why is this a "poor example"?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://867800]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found