#!/usr/bin/perl -w
use strict;
use OLE;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
print "Content-type: text/html\n\n";
print "init <BR>";
my $Excel = CreateObject OLE 'Excel.Application';
print "excel init_ <BR>";
my $Book = $Excel->Workbooks->Open("D:/template.xls");
print "excel file loaded <BR>";
my $Sheet = $Book->Worksheets(1);
foreach my $row (1..9)
{
foreach my $col (1..3)
{
next unless defined $Sheet->Cells($row,$col)->{'Value'};
printf "At ($row, $col) the value is %s and the formula is %s\n",
$Sheet->Cells($row,$col)->{'Value'},
$Sheet->Cells($row,$col)->{'Formula'};
}
}
$Sheet->Cells(6, 1)->{'Value'} = 'MODTEST';
print "excel file modified <BR>";
$Book->SaveAs({Filename =>'D:/record.xls',
FileFormat => xlWorkbookNormal});
print "excel file saved <BR>";
$Book->Close;
$Excel->Quit();
print "excel quit successfully<BR>";