in reply to Re: Spreadsheet::ParseExcel Script Fails to Parse (access) Excel Spreadsheet
in thread Spreadsheet::ParseExcel Script Fails to Parse (access) Excel Spreadsheet
I added the strict and warnings and heeded the ensuing warnings. I added my to my variables. I also eliminated any DBI and other distacting code from the script. The script compiles properly, but I still don't get any output from my print statements which implies the file is not getting parsed.
#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; my $file = "\\lebensraum\\perl\\SAMReport.xls"; my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($file)or die " +Unable to open $file\n"; #locate columns in the spreadsheet from which we want to extract data foreach my $sheet (@{$workbook->{worksheet}}) { print "Sheet number $sheet\n"; foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) { if ($sheet->{Cells}[0][$col]->{Val} eq "Site Number") { my $siteid = $col; print "$siteid\n";} else {print "Could not find column Site Number\n";} if ($sheet->{Cells}[0][$col]->{Val} eq "Site Name") { my $name = $col; print "$name\n";} else {print "Could not find column Site Name\n";} if ($sheet->{Cells}[0][$col]->{Val} eq "City") { my $city = $col; print "$city\n";} else {print "Could not find column City\n";} } #iterate through spreadsheet rows and extract site.siteid,site.name & +site.city foreach my $row ($sheet->{MinRow}+1 .. $sheet->{MaxRow}) { my $site_number = $sheet->{Cells}[$row][my $siteid]->{Val}; my $site_name = $sheet->{Cells}[$row][my $name]->{Val}; my $site_city = $sheet->{Cells}[$row][my $city]->{Val}; print "$site_number\n"; print "$site_name\n"; print "$site_city\n"; } } exit;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Spreadsheet::ParseExcel Script Fails to Parse (access) Excel Spreadsheet
by bmann (Priest) on Sep 19, 2008 at 22:58 UTC | |
by finhagen (Sexton) on Sep 20, 2008 at 05:06 UTC | |
by Anonymous Monk on Sep 20, 2008 at 06:58 UTC | |
by finhagen (Sexton) on Sep 22, 2008 at 00:43 UTC |
In Section
Seekers of Perl Wisdom