Using xlswrite with Excel 2013
2 views (last 30 days)
Show older comments
I have a new Windows 8 laptop running MS Office 2013 and MATLAB R2013a.
The xlswrite function does not seem to work with this version of Excel®. A program developed at my school's computer lab using academic site-license MATLAB R2013 and MS Office 2010 under Win 7 worked fine in the development environment but shows fatal errors on this laptop when trying to write to an Excel 2013 spreadsheet. The program reads the names (strings) of purchasers and items, and weights (floating point numbers) of items out of an excel worksheet using xlsread, processes the data, and outputs processed data to an empty area of the worksheet. Our Excel files are in .xlsx format, not .xls.
The program fails with this error message:
Error using xlswrite (line 220)
Error registering event(s), Advise failed
Error in myprogram (line 164)
xlswrite(file, wt(n), worksheet, [alph({person{1} (3))} num2str(n)]);|
We are sure that the problem does not lie with the file and worksheet name nor the variable types, brackets or indices because the routine works perfectly under Win 7 and Excel 2010.
Besides outputting to a text file, is there any way to fix this?
0 Comments
Accepted Answer
Mihir Pai
on 27 Jun 2014
Hey susato! I'm sorry if this comes a year too late but I thought I might as well share my experience with this in case anyone else stumbles across this error.
I got this error on the n-th iteration of my tremendously huge for loop which caused it to break out of the loop and terminate the program. What seemed to be happening with my case is that each successive loop of the code accessed the MATLAB's Excel drivers in a read/write execution and started filling up the RAM with instructions to the point where the read/write executions failed as you mentioned.
What solved it was adding a pause() for about 5 seconds before the next iteration of the loop. What also helped was not having too many open xls/xlsx spreadsheets at the time since this too fills up your RAM (I ran numerous stress tests to confirm this, and yes the added 5 seconds lengthened my run time considerably).
In summary: leave MATLAB alone to do its thing since the handshake with Excel is pretty aggressive in memory consumption.
Hope this helps!
- Mihir
PS: I run MATLAB R2012b/R2014a on an i7 - 2.1 GHz with 8 GB RAM on Windows 8/8 Pro, Microsoft Office 2010/2013
2 Comments
Beneyaz Begum
on 19 Jan 2022
Edited: Beneyaz Begum
on 19 Jan 2022
Thank you Mihir and Susato. I am also running a similar problem statement with xlswrite() using for loop for 25 different patterns. And each pattern loops for multiple number of times. When I am opening multiple matlab editor to run different expeiments, with 2 or 3 editors it turns out to be too slow for my workstation.
Today, I encountered a similar such error with my experiment. Atleast, now I could really find an answer to what is really happening at the backend. Thanks for suggesting the solution.
Regards,
Beneyaz
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!