Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; use Spreadsheet::ParseExcel; my $file = "../my_file.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"; 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"; } } 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][$identification]->{V +al}; print "\n$got_user_name\n$got_user_number\n$got_identification\n"; } } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing XLS file Help!
by jmcnamara (Monsignor) on Oct 27, 2010 at 16:57 UTC | |
|
Re: Parsing XLS file Help!
by larryl (Monk) on Oct 27, 2010 at 16:16 UTC | |
|
Re: Parsing XLS file Help!
by Tux (Canon) on Oct 27, 2010 at 18:46 UTC | |
|
Re: Parsing XLS file Help!
by Jim (Curate) on Oct 27, 2010 at 16:25 UTC | |
|
Re: Parsing XLS file Help!
by umasuresh (Hermit) on Oct 27, 2010 at 15:00 UTC | |
|
Re: Parsing XLS file Help!
by cjb (Friar) on Oct 27, 2010 at 16:50 UTC | |
by cjb (Friar) on Oct 27, 2010 at 17:00 UTC | |
by Anonymous Monk on Oct 27, 2010 at 18:06 UTC |