File Exchange

image thumbnail

write2excel

version 1.0 (3.7 KB) by

Writes data to multiple ranges of existing Excel file.

4.42105
18 Ratings

10 Downloads

Updated

View License

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

Comments and Ratings (21)

xiaoyu he

Natalylun

Thank you for the excellent code!

Julia

Julia (view profile)

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

Julia

Julia (view profile)

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

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

Arthur

Arthur (view profile)

mm pp

R. Pelaez

Thanks a lot for your work.

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!

LI JING

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

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!

g w

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

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

kim l

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

AHMET ANIL DINDAR

Really good file. Very versatile...

Rohan More

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

Onur Uncu

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

Daniel Camp

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

Andre Camenzind

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

Beautiful piece of code

martyn dorey

Very practical routine. Good effort.

Urs Schwarz (us)

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

Updates

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.

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.

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.

MATLAB Release
MATLAB 6.5 (R13)
Acknowledgements

Inspired: MATLAB read/write/control Excel, MAT2XLS v2.0

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

» Watch video