View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.0 | 5 ratings Rate this file 8 Downloads (last 30 days) File Size: 1.81 KB File ID: #9209 Version: 1.0




01 Dec 2005 (Updated )

This function inserts a picture into an Excel file

| Watch this File

File Information


pic2xls : Inserts a picture into an Excel file
pic: image file name (.gif,.jpg,.bmp,..etc)
file: Excel file name (new or existing)
sheet: sheet name.
param: consists of a row of 4 numbers:
          [left top width height]
          left: image location from left side (pixels)
          top: image location from top side (pixels)
          width: image width (pixels)
          height: image width (pixels)
pic = 'tree.jpg';
file = 'file.xls';
pic2xls(pic,file,'Sheet1',[0 0 200 200]);

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements Microsoft Excel
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
11 Apr 2014 chrissie xiao

23 May 2008 Christian Jardim

Excelent work...

I've got a problem using this function, however.. Lately I've been working on generating an automated Excel report. This report contains some figures which were imported from MATLAB using your code..
Since these figures are pasted into my report (and saved), they are still there when I try to generate the next report.. This way, everytime I finish a report, I have to save it to another file and manually remove the figures, to avoid overlapping the next time I run the report generator program..
My question is: Is there a Matlab routine (or activex command) to delete the figures (in an Excel spreadsheet) so they will not be present when a new report is generated???

Hope you can give me a clue...

Thanks in advance..


26 Mar 2007 Steve Jacob

I was able to use it and it produced the results I needed without much difficulty.

18 Oct 2006 Tamir Suliman

Hello Fahad

There is an error occurs when we tried to run the file.I tried to tell the the Function on m files written the location or the destination of the picture and the files I think that what solves the Invoke problem but still no results imported to the excel file

thats what I did

pic = 'C:\Documents and Settings\Engr.Tamir Suliman\Desktop\005.jpg';
file = 'C:\Documents and Settings\Engr.Tamir Suliman\Desktop\new.xls';
pic2xls(pic,file,'Sheet1',[0 0 200 200]);

I tried 1 and sheet1 but still didnt work

04 Jan 2006 Fahad Al Mahmood

First I would suggest that you try to write the following command format:

pic2xls(pic,file,1,[0 0 200 200]);

Where (1) means the first sheet. So just write the number of the sheet you want to put the picture into .......... If it doesn't work, then let me know.

Comment only
04 Jan 2006 Veronika Pol

I need very this program, but I always get this error! Where
can lie??
Yours sincerely

??? Invoke Error, Dispatch Exception: Ung├╝ltiger Index.

Error in ==> pic2xls at 61
sheet = get(Sheets, 'Item', sheet);

Contact us