hi all,
i've got the following program that needs yr help:
[CODE=perl]
use Win32::OLE;
# use existing instance if Excel is already running
eval {$ex = Win32::OLE->GetActiveObjec t('Excel.Applic ation')};
die "Excel not installed" if $@;
unless (defined $ex) {
$ex = Win32::OLE->new('Excel.App lication', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
# get a new workbook
$book = $ex->Workbooks->Add;
$sheet = $book->Worksheets(1 );
# write a 2 rows by 3 columns range
$sheet->Range("A1:J2 ")->{Value} = [['Date','Total (IN)','Succ (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ (OUT)','MO(IN)' ,'MO(OUT)'],
[$date, $total_in, $succ_in,$pk_in ,$pk_out,"$pk_h our - $pk_hour_dur hr",$total_out, $succ_out ]];
$sheet->Range("K1:L2 ")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'],
[$max_pk_msg,$pk _msg]];
foreach(@parame ters)
{
$sheet->Cells(2,9)->{Value} = [$parameter_in_a rray{$_}];
$sheet->Cells(2,10)->{Value} = [$parameter_out_ array{$_}];
}
# print "XyzzyPerl"
$array = $sheet->Range("A2:I1 ")->{Value};
for (@$array) {
for (@$_) {
print defined($_) ? "$_|" : "<undef>|";
}
print "\n";
}
# save and exit
$book->SaveAs ("C:\\Docume nts and Settings\\clong \\Desktop\\perl \\$save_file_na me.xls") ;
undef $book;
undef $ex;
[/CODE]
this code outputs everything to an excel sheet
however i need to append the data
how will i go about trying to determine the last row and insert it?
i considered using a counter but then i still need to determine the new cells of that the new data will go in
tough problem here, anyone pls advise?
thanks
i've got the following program that needs yr help:
[CODE=perl]
use Win32::OLE;
# use existing instance if Excel is already running
eval {$ex = Win32::OLE->GetActiveObjec t('Excel.Applic ation')};
die "Excel not installed" if $@;
unless (defined $ex) {
$ex = Win32::OLE->new('Excel.App lication', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
# get a new workbook
$book = $ex->Workbooks->Add;
$sheet = $book->Worksheets(1 );
# write a 2 rows by 3 columns range
$sheet->Range("A1:J2 ")->{Value} = [['Date','Total (IN)','Succ (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ (OUT)','MO(IN)' ,'MO(OUT)'],
[$date, $total_in, $succ_in,$pk_in ,$pk_out,"$pk_h our - $pk_hour_dur hr",$total_out, $succ_out ]];
$sheet->Range("K1:L2 ")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'],
[$max_pk_msg,$pk _msg]];
foreach(@parame ters)
{
$sheet->Cells(2,9)->{Value} = [$parameter_in_a rray{$_}];
$sheet->Cells(2,10)->{Value} = [$parameter_out_ array{$_}];
}
# print "XyzzyPerl"
$array = $sheet->Range("A2:I1 ")->{Value};
for (@$array) {
for (@$_) {
print defined($_) ? "$_|" : "<undef>|";
}
print "\n";
}
# save and exit
$book->SaveAs ("C:\\Docume nts and Settings\\clong \\Desktop\\perl \\$save_file_na me.xls") ;
undef $book;
undef $ex;
[/CODE]
this code outputs everything to an excel sheet
however i need to append the data
how will i go about trying to determine the last row and insert it?
i considered using a counter but then i still need to determine the new cells of that the new data will go in
tough problem here, anyone pls advise?
thanks
Comment