Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Inserting Image in Excel using Win32::OLE

by the_hawk_1 (Scribe)
on May 25, 2007 at 20:43 UTC ( [id://617606]=perlquestion: print w/replies, xml ) Need Help??

the_hawk_1 has asked for the wisdom of the Perl Monks concerning the following question:

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?

Replies are listed 'Best First'.
Re: Inserting Image in Excel using Win32::OLE
by bmann (Priest) on May 25, 2007 at 22:16 UTC
      Merci beaucoup! Thanks a lot!

      It helped me a lot, in fact, more than expected. I also tried succesfully to generated VBA and translate. Thanks!

      Unfortunately, I get another bug, the use of
      with (...);
      doesn't work!

      May you help me again?

Re: Inserting Image in Excel using Win32::OLE
by runrig (Abbot) on May 25, 2007 at 22:00 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://617606]
Approved by kyle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found