Hello All,
I am newbee for perl scripting. I am writing a script to update an excel sheet daily. MyScript:
================================================== ========
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
# open Excel file
my $workbook = $Excel->Workbooks->Open("E:\\poolsize_BLRKCF9A_1.xls");
my $worksheet = $workbook->Worksheets(1);
my $LastRow = $worksheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByRows})->{Row};
print "\nmmmmm = $LastRow";
$datetime=localtime();
# $count variable is used to track the no of in the excel
$count=0;
#$loc=$ENV{"TEMP"};
#$loc="D:\\VOBSpaceUsage";
$vob="";
$vobsize=0;
$totalvobsize+=0;
$vd="";
$sum=0;
#$worksheet->write($count,0,"Updated on $datetime",$format);
#$worksheet->write($count,1,"VOB Name",$format);
#$worksheet->write($count,2,"db",$format);
#$worksheet->write($count,3,"cdft",$format);
#$worksheet->write($count,4,"ddft",$format);
#$worksheet->write($count,5,"sdft",$format);
#$worksheet->write($count,6,"Total Size in (MB)",$format);
#$worksheet->write($count,7,"Total VOB Size in (GB)",$format);
#@vobs = `ct lsvob -s -host blrkcf9a`;
@vobs= ("\\AXIS");
foreach $vob (@vobs)
{
$vobname=$vob;
chomp($vobname);
#chop($vobname);
print "\n VOB Name :: $vobname \n";
@vobdiskuse = `cleartool space -vob -update $vob`;
foreach $vd (@vobdiskuse)
{
if ($vd =~ /VOB database/)
{
if ($vd =~ /(\d+\.\d+)\s+/)
{
$dbsize = $1;
# print "\n DB Pool:$dbsize Mb\n";
}
}
if ($vd =~ /cleartext/)
{
if ($vd =~ /(\d+\.\d+)\s+/)
{
$csize = $1;
# print "\n C Pool:$csize Mb\n";
}
}
if ($vd =~ /derived object/)
{
if ($vd =~ /(\d+\.\d+)\s+/)
{
$dosize = $1;
# print "\n DO Pool:$dosize Mb\n";
}
}
if ($vd =~ /source pool/)
{
if ($vd =~ /(\d+\.\d+)\s+/)
{
$srcsize = $1;
# print "\n SOURCE Pool:$srcsize Mb\n";
}
}
if ($vd=~ /^Total*/)
{
chomp($vd);
if ($vd=~ /\s(\d+\.\d+)\s/)
{
$vobsize=$1;
chomp($vobsize);
# print "VOB Size :: $vobsize \n";
$row = $LastRow+1;
#$worksheet->Cells($row,1)->{'Value'}= $vobname;
#$worksheet->Cells($row,2)->{'Value'}= $dbsize;
#$worksheet->Cells($row,3)->{'Value'}= $csize;
#$worksheet->Cells($row,4)->{'Value'}= $dosize;
#$worksheet->Cells($row,5)->{'Value'}= $srcsize;
#$worksheet->Cells($row,6)->{'Value'}= $vobsize;
}
$totalvobsize+=$vobsize;
$totalvobsize = ($totalvobsize / 1024);
$sum+=$totalvobsize;
print "\nTotal Vobsize: $totalvobsize GB \n";
#$worksheet->Cells($row,7)->{'Value'}= $totalvobsize;
}
}
$row++;
}
#$worksheet->Cells($row,7)->{'Value'}=$sum;
$workbook->Close;
================================================== ========
I am getting the following error:
D:\admin\perl_scr>perl spaceusage_excel_pools2.pl
No type library matching "Microsoft Excel" found at spaceusage_excel_pools2.pl line 2
Win32::OLE(0.1701): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/site/lib/Win32
/OLE/Const.pm line 45.
Win32::OLE(0.1701) error 0x800401f3: "Invalid class string" at spaceusage_excel_pools2.pl line 7
eval {...} called at spaceusage_excel_pools2.pl line 7
Thanks in Advance,
Raghavendra S: eek: