Hi
I am having a similar issue with my script. I've tried this solution and a lot of others but as yet am unable to get my script to skip empty rows.
I do get some output (
the dates) and these errors with blank lines in between ( I'm assuming the blank lines are the empty cells in my spreadsheet ).
2012-11-01Use of uninitialized value in scalar chomp at
test.pl line 50.
Use of uninitialized value in hash element at
test.pl line 51.
Use of uninitialized value in concatenation (.) or string at
test.pl line 51.
2012-01-01Use of uninitialized value in scalar chomp at
test.pl line 50.
Use of uninitialized value in hash element at
test.pl line 51.
Use of uninitialized value in concatenation (.) or string at
test.pl line 51.
My script looks like this
#!/usr/bin/perl -w
use Spreadsheet::ParseExcel;
my $cell;
my $row_min;
my $row_max;
my $col_min;
my $col_max;
my %account_chg_date;
my @account_names;
my $key;
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('test2.xls');
if ( !defined $workbook ) {
die $parser->error(), ".\n";
}
for my $worksheet ( $workbook->worksheet(0) ) {
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
ROW:
for my $row ( $row_min .. $row_max ) {
next if ($row == 0);
for my $col ( $col_min .. $col_max ) {
if ($col == 0 || $col == 2) {
my $cell = $worksheet->get_cell( $row, $col );
if (($col == 0) and (defined $cell) and ($cell->value() ne '')) {
$account_names[$row]= $cell->{_Value};
}elsif (defined $cell and $cell->value() ne ''){
$account_chg_date{$account_names[$row]} = $cell->{_Value};
}
}
}
}
}
while (@account_names){
chomp ($key = pop @account_names);
print "$account_chg_date{$key}\n"
}
Any help would really be appreciated.
Tanscia