B
Buck Turgidson
I am a very weak Perl programmer, but I have managed to put the following
together, based on some examples I've found on the web.
However, I receive a long series of the following error message, but the
problem is it is not consistent as to where it begins and ends (i.e. which
cell in the Excel spreadsheet). This leads me to believe I am overstepping
some memory, or not using variables correctly. I do not think there is
anything wrong with the spreadsheet.
I would be grateful if someone could tell me the error of my ways. I don't
even expect politeness.
"Use of uninitialized value in printf at h:\dev\perl\readbudget.pl line 29"
#!/usr/bin/perl -w
#use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open("d:\\misc\\bud.xls");
my $Sheet = $Book->Worksheets('bud_05');
$LastRow =
$Sheet->UsedRange->Find({What=>"*",SearchDirection=>xlPrevious,SearchOrder=>
xlByRows})->{Row};
$LastCol = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,SearchOrder=>xlByColumns})->{Column};
foreach my $row (2..$LastRow)
{
my $descr1 = $Sheet->Cells($row,1)->{'Value'};
my $descr2 = $Sheet->Cells($row,2)->{'Value'};
my $descr3 = $Sheet->Cells($row,3)->{'Value'};
my $descr4 = $Sheet->Cells($row,4)->{'Value'};
foreach my $col (5..$LastCol)
{
my $budval = $Sheet->Cells($row,$col)->{'Value'};
printf
"%d,%d,%s,%s,%s,%s,%d\n",$row,$col,$descr1,$descr2,$descr3,$descr4,$budval;
}
}
$Book->Close;
together, based on some examples I've found on the web.
However, I receive a long series of the following error message, but the
problem is it is not consistent as to where it begins and ends (i.e. which
cell in the Excel spreadsheet). This leads me to believe I am overstepping
some memory, or not using variables correctly. I do not think there is
anything wrong with the spreadsheet.
I would be grateful if someone could tell me the error of my ways. I don't
even expect politeness.
"Use of uninitialized value in printf at h:\dev\perl\readbudget.pl line 29"
#!/usr/bin/perl -w
#use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open("d:\\misc\\bud.xls");
my $Sheet = $Book->Worksheets('bud_05');
$LastRow =
$Sheet->UsedRange->Find({What=>"*",SearchDirection=>xlPrevious,SearchOrder=>
xlByRows})->{Row};
$LastCol = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,SearchOrder=>xlByColumns})->{Column};
foreach my $row (2..$LastRow)
{
my $descr1 = $Sheet->Cells($row,1)->{'Value'};
my $descr2 = $Sheet->Cells($row,2)->{'Value'};
my $descr3 = $Sheet->Cells($row,3)->{'Value'};
my $descr4 = $Sheet->Cells($row,4)->{'Value'};
foreach my $col (5..$LastCol)
{
my $budval = $Sheet->Cells($row,$col)->{'Value'};
printf
"%d,%d,%s,%s,%s,%s,%d\n",$row,$col,$descr1,$descr2,$descr3,$descr4,$budval;
}
}
$Book->Close;