If so, the following should work.
#!/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$got_user_name\n$got_user_number\n$got_identifica
+tion\n";
}
}
}
exit;
|