View License

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

» Watch video

Highlights from
improved xlswrite.m

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

5.0
5.0 | 12 ratings Rate this file 48 Downloads (last 30 days) File Size: 6.12 KB File ID: #27236 Version: 1.0

improved xlswrite.m

by

 

Makes xlswrite use 'persistent' actxserver and hence much faster

| Watch this File

File Information
Description

If writing or reading repeatedly to same spreadsheets very slow to keep creating and deleting the active x server. These extra 4 lines of code cause xlswrite to remember if you accessed this spreadsheet before and then not re-create the active x server.

Acknowledgements

This file inspired Despiking Acoustic Doppler Velocimeter (Adv) Data and Microscopy Image Browser (Mib).

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (20)
21 Jul 2016 Barry Dillon

Can't believe it is 6 years since I made this submission!! I'm surprised it is underperforming the normal matlab version but of course they may have improved their version. Against that on 11 July 2016 it seemed to help Pratik. All it does is prevent Matlab creating a new activeXserver every time you write so helpful if you have lots of small writes when you don't want to keep creating new servers. Don't actually know why it would run out of storage faster for Rajesh. Maybe there is some house cleaning happens with all the deletes and recreates as envisaged originally by matlab. Generally lack of deletes has not been a problem and of course faster to not make a new server each time. It must be a different profile of data from Rajesh that does not suit the continuous re-use of the same server. Sorry I can't be more helpful. ps. I still get emails thanking me for this small piece of code. I tell people releasing a piece of open source code involves zero ongoing effort in return for endless gratitude. The opposite of marriage.

Comment only
20 Jul 2016 Rajesh Rajaram

I used this function to dump large amounts of data into multiple sheets in an excel file. The function did increase the speed (~15% for the overall code), but it eventually seems to be crashing due to lack of storage, while the Matlab's version seems to be chugging well past that crash point. Any ideas?

Comment only
11 Jul 2016 Pratik Nadkarni

The code drastically reduces the time of xlswrite function. Works wonderfully. Thank you so much . Great work

09 Jul 2016 Pratik Nadkarni  
07 Apr 2016 James Ang

Hi, I'm using 2015b.

I downloaded and unzipped the file, placed the 'improved' xlswrite in my current folder together with the m-file I'm working with, disabled the built-in function by removing E:\matlab\toolbox\matlab\iofun from the Matlab path.

I typed
>>which xlswrite -all
and only saw the 'improved' version shown.

I then ran the codes but from the tic toc timer the reading is about 50-ish secs, almost similar to the built-in xlswrite function, also about 50-ish secs.

Did I use the function incorrectly?

Comment only
20 May 2015 Ilya Belevich  
30 Apr 2015 Suraj Srivastava

HI,

How can I use this function in GUI?

As I have downloaded this file and kept it in my current foldeer. After that I ran the code, but the speed did'nt got improved.

Kindly help me out.

Thanks,
Suraj

23 Feb 2015 Biagio Ciuffo

Hi,
I have a model implemented in a spreadsheet and I want to check the results for different combinations of the input parameters. So I made a loop and at each step I use Matlab to write in the excel file the and afterwards to read the value of a specific cell (output of the model). Since I need to do it n thousands of time I was looking for a solution alternative to xlswrite. I tried to modification posted here but I don't see any difference in the performance. I run MATLAB R2014a on a Windows Server 2008 R2 and Excel 2010.
Any suggestion?
Thanks

Comment only
05 Feb 2015 Maggie

Maggie (view profile)

I downloaded the zip file, but when I tried to run the code I get an error of not enough input arguments. How do I properly incorporate this improved xlswrite for my use?

Comment only
28 Nov 2014 meli

meli (view profile)

hi
how can i download this file please?
thanks

Comment only
16 Sep 2014 Dave Perry

THANK-YOU x 10! - this code works much faster than the original version (on Win7 - 32b - with 2013a)

21 May 2014 Marco Marino

With just 4 lines of code my script has become 4 times faster!

Cheers man!

02 May 2013 Victor

Victor (view profile)

 
27 Mar 2013 Daniel

Daniel (view profile)

 
27 Mar 2013 Daniel

Daniel (view profile)

Oh my god, I can't thank you enough!! I am using MATLAB to locate particles in over 9,000 images and then write location data to excel. This has sped things up incredibly!

Comment only
03 Aug 2012 K E

K E (view profile)

Do I need to rename this to xlswrite1.m to distinguish it from the builtin xlswrite?

28 Nov 2011 Sebastian W

I optimized my program before I found this and only got 3 write commands left, but this new xlswrite function is roughly 10 times faster.
Thanks Barry.

31 Jul 2011 Fernando tyffing

Works very good, priori to using this it was impossible to run parfor creating a lot of xls files.

11 Nov 2010 Stan Young

Does this leave anything open in the background that would be of concern if writing a large number of spreadsheets - sort of like leaving file pointers open?

Comment only
04 Jul 2010 Milkykung

Thank you very much for your effort in going into details of ActiveX server when dealing with xls file using MATLAB.

I have to admit that I have no clue what is going when my xlswrite is running as I know superficially that ActiveX server has to be created and I simply use it. I realise your powerful correction of the xlswrite when I struggle to run 7-8 lines of xlswrite continuosly for 360 times and it kept crashing. I have been trying to run it for 2-3 days and it ends up the same way sooner or later. I have to divide it and run seperately but still a painful delay causes freezing several times.

I totally appreciate on what you have done on this and your contribution is highly regarded as a life and time-saver. I can have my program running and getting results thanks to you.

Thank you very much again and please keep it up.

Kind regards,

Contact us