3.25

3.2 | 4 ratings Rate this file 129 downloads (last 30 days) File Size: 1.81 KB File ID: #9209

pic2xls

by Fahad Al Mahmood

 

01 Dec 2005 (Updated 12 Dec 2005)

Code covered by BSD License  

This function inserts a picture into an Excel file

Download Now | Watch this File

File Information
Description

pic2xls(pic,file,sheet,param)

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)
  
Example:
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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
04 Jan 2006 Veronika Pol

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

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.

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

26 Mar 2007 Steve Jacob

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

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

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Fahad Al Mahmood 22 Oct 2008 08:08:11
data export Fahad Al Mahmood 22 Oct 2008 08:08:11
xls Cristina McIntire 10 Dec 2008 17:06:49
activex Cristina McIntire 10 Dec 2008 17:06:49
spreadsheet Cristina McIntire 10 Dec 2008 17:06:49
excel Cristina McIntire 10 Dec 2008 17:06:49
picture Cristina McIntire 10 Dec 2008 17:06:49
sheet Cristina McIntire 10 Dec 2008 17:06:49
insert Cristina McIntire 10 Dec 2008 17:06:49
jpg Cristina McIntire 10 Dec 2008 17:06:49
gif Cristina McIntire 10 Dec 2008 17:06:49
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com