File Exchange

image thumbnail


version 1.0 (1.81 KB) by

This function inserts a picture into an Excel file



View License


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]);

Comments and Ratings (6)

chrissie xiao

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

Steve Jacob

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

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

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.

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);

MATLAB Release
MATLAB 7.0.1 (R14SP1)

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

» Watch video