You can insert an image into an Excel file, but not a csv. Excel will strip the image out and only save the data when it is saved to csv.
To see how it's done in an xls, fire up the macro recorder in Excel then insert your image. Now move the image. Stop the macro recorder and open up Excel's VBA IDE. Take the generated code and convert it to perl.
use strict;
use warnings;
use Win32::OLE;
my $excel = Win32::OLE->CreateObject('Excel.Application');
$excel->{Visible} = 1;
my $wb = $excel->Workbooks->Add;
$wb->ActiveSheet->Pictures->Insert( "C:\\s\\x.png" )->Select;
$excel->Selection->ShapeRange->IncrementLeft( 40 );
$excel->Selection->ShapeRange->IncrementTop( 40 );
__END__
Sub Macro1()
' Macro recorded with Macro Recorder
' Tools -> Macro -> Record new macro
ActiveSheet.Pictures.Insert( _
"C:\s\x.png").Select
Selection.ShapeRange.IncrementLeft 40
Selection.ShapeRange.IncrementTop 40
End Sub
Voila, done! BTW, you probably want to read the definitive thread on Excel and Win32::OLE, Using Win32::OLE and Excel - Tips and Tricks.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|