Hi monks!
I'm using Win32::OLE to create an Excel (.xls) file and I wish to include an image.
Here is a part of my code:
#!/usr/local/bin/perl
use Win32::OLE;
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application','Quit')};
die "Excel not installed" if $@;
unless (defined $ex) {
$ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
$ex->{visible} = 0; # Hide excel to the operator
$ex->{DisplayAlerts}=0; # Stops the alerts of excel
$ex->{SheetsInNewWorkbook} = 1; # Set the number of sheets in workboo
+k
$tb = $ex->Workbooks->Add; # Create the new workbook
$sheet = $tb->WorkSheets(1); # Select the sheet
$sheet->Range("A:Z")->Font->{Name} = "Arial";
$sheet->Range("A:Z")->Font->{Size} = 10;
$sheet->Cells(2,1)->{Value} = "Campagne:";
$sheet->Cells(3,1)->{Value} = "Rapport:";
$sheet->Cells(5,1)->{Value} = "Journée d\'appel:";
$sheet->Cells(6,1)->{Value} = "Date du rapport:";
$sheet->Cells(2,1)->Font->{size} = 12;
$sheet->Cells(3,1)->Font->{size} = 12;
$sheet->Cells(2,1)->Font->{bold} = 1;
$sheet->Cells(3,1)->Font->{bold} = 1;
GetDate();
$sheet->Cells(6,2)->{Value} = "$annee-$mois-$jour $heure:$min:$sec";
...
$tb->SaveAs($NetworkFileName);
$tb->Quit;
undef $tb;
undef $ex;
Win32::OLE->FreeUnusedLibraries();
## SUBS ########################################################
sub GetDate() {
($sec,$min,$heure,$jour,$mois,$annee,$jour_se,$jour_an,$ete) = loc
+altime( time );
$annee+=1900;
$mois+=1;
if($mois<10) {$mois="0".$mois;}
if($jour<10) {$jour="0".$jour;}
if($heure<10) {$heure="0".$heure;}
if($min<10) {$min="0".$min;}
if($sec<10) {$sec="0".$sec;}
}
I don't have the spredsheet::writeExcel installed and I'm running activeperl on Win XP pro.
May I beg for your enlightment?