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. |