Code covered by the BSD License  

Highlights from
write2excel

4.93333

4.9 | 16 ratings Rate this file 19 Downloads (last 30 days) File Size: 3.7 KB File ID: #4414

write2excel

by Brett Shoelson

 

28 Jan 2004 (Updated 15 Oct 2004)

Writes data to multiple ranges of existing Excel file.

| Watch this File

File Information
Description

Uses ActiveX commands to write data_n into range_n in an existing Excel spreadsheet. Inputs (excluding fileloc and promptforsave) must be paired.

As of 10/04 update, you may provide the target range (upper left cell to lower right cell) OR just the upper right cell. If the range is specified, the function will verify that the corresponding data block is the correct size, and give an error if not. (This may be useful for error checking, for instance.) If only the upper left cell is provided, write2excel will now compute the target range.

Additionally, you may now specify cells by address (eg., 'H3') OR row, column (eg, '[3,8]').

SEE ALSO: readfromexcel

Acknowledgements
This submission has inspired the following:
MATLAB read/write/control Excel, MAT2XLS v2.0
MATLAB release MATLAB 6.5 (R13)
Other requirements Tested under R12.1 and R13. Requires Windows environment and Microsoft Excel.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (19)
05 Feb 2004 Urs Schwarz (us)

excellent add-on for users running in a typical wintel environment! should be included in the basic package.

13 Feb 2004 martyn dorey

Very practical routine. Good effort.

11 Mar 2004 Andre Camenzind

Wonderful - can't believe there wasn't capacity to do this already actually.

Beautiful piece of code

22 Jun 2004 Daniel Camp

This is an excellent function. It is one of the essential functions I have used in writing a data aquisition script.

13 Jul 2004 Onur Uncu

I use this function all the time. Very handy and simple. Brett did a great job!

14 Jul 2004 Rohan More

This is the best command. It makes life very easy.

09 May 2005 AHMET ANIL DINDAR

Really good file. Very versatile...

31 Aug 2006 kim l

the file woks fine, but exel exel shoul be a forbiden program for humans! SO this file just can be bad!

31 Jan 2007 Alex Ross

Very useful command, thx!
The only thing is that when i call this function, the program take like 30 secs tu run it, is there a way it can be faster??
Thx

15 Feb 2007 g w

excellent, just solved my problem! you are the best.

16 Apr 2007 Mario Trevino Villegas

Excellent program! Now Im storing thousands of graphs and results in predefined excel files. Excellent to share data with excel users. Thanks a lot!

14 Aug 2007 LI JING

It's a good method to integrate datas of experiment to a computing software

27 Sep 2007 Ruoyu Cheng

It can be further improved if multiple sheets can be writen by just calling this function once as to function 'readfromexcel'. Thanks for this excellent work!

13 Feb 2008 R. Pelaez

Thanks a lot for your work.

09 Oct 2008 mm pp  
26 Mar 2009 Arthur  
27 Aug 2009 Pete sherer

Why do I get this error message?

??? Error using ==> Write2Excel at 157
Sorry...unable to open file ./loss_summary_v11_IEDv11_20090827_1438.xls

I checked the file path, and the file exists.
K>> exist(fileloc,'file')
ans =

     2

11 Nov 2009 Julia

Dear Brett,

I know excel is evil and doesn't implement the NaN standard, but is there a way to get your program to write something sensible, like "-" or ".." to a cell when the data array has an NaN?

Right now it writes 65535 for me, which is far to close to a real number to be helpful.

Cheers and thanks for the great coding,
Julia
 

11 Nov 2009 Julia

and one more thing: is there a way to give input information regarding the sheet one wants to be written to?

Please login to add a comment or rating.
Updates
03 Feb 2004

Now allows multiple specifications of sheet name (at the suggestion of R. Venkat), and support of relative paths (thanks to Urs Schwarz). Also, incusion of the extension '.xls' is now superfluous.

03 Feb 2004

Now allows multiple specifications of sheet name (at the suggestion of R. Venkat), and support of relative paths (thanks to Urs Schwarz). Also, incusion of the extension '.xls' is now superfluous.

05 Oct 2004

Now allows "dynamic specification" of cell ranges, and specification of cells by row, column format. (You no longer need to pre-determine the target range; simply provide the address OR row-column index of the upper left corner of the target range.

15 Oct 2004

Recently modified version accidentally had changes incorporated into an old version. This version should now work properly.

Tag Activity for this File
Tag Applied By Date/Time
data import Brett Shoelson 22 Oct 2008 07:13:29
data export Brett Shoelson 22 Oct 2008 07:13:29
excel Brett Shoelson 22 Oct 2008 07:13:29
write spreadsheet Brett Shoelson 22 Oct 2008 07:13:29
activex Brett Shoelson 22 Oct 2008 07:13:29
data Brett Shoelson 22 Oct 2008 07:13:29
import Brett Shoelson 22 Oct 2008 07:13:29
utilities Brett Shoelson 22 Oct 2008 07:13:29

Contact us at files@mathworks.com