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?


In reply to Inserting Image in Excel using Win32::OLE by the_hawk_1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.