xlswrite function works once, then throws error - Error using xlswrite (line 226) Invoke Error, Dispatch Exception: Source: Microsoft Excel Description: Add method of Workbooks class failed
94 次查看(过去 30 天)
显示 更早的评论
Hi All
I have a strange problem that has only recently started occurring. When I try to execute xlswrite I get the following error:
Error using xlswrite (line 226)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Add method of Workbooks class failed
Help File: xlmain11.chm
Help Context ID: 0
I'm running Windows 10 64 bit, Matlab r2018 64bit and Office 365
I've been using xlswrite within my image analysis GUI for about 2 years and it has always worked fine. This error has only started occuring in the last 2 weeks, and only on the second execution. e.g. I save data to excel fine, open another image for analysis, try to save the data again and this error occurs. This has never happened previously after years of use, and the script has not changed.
I have tried a very simple call outside of the GUI "xlswrite('test.xlsx', 1)" and the error occurs again. If i restart Matlab the function will run properly once, then re-occur.
Any ideas? Thanks
Ryan
1 个评论
Walter Roberson
2021-5-31
I seem to recall that the most common cause of this error was if certain add-ons were enabled in Excel. My memory is prompting me as "especially Fox-It", but my memory is not always right ;-)
采纳的回答
更多回答(1 个)
Chidvi Modala
2021-6-8
A possible reason for this error can be the COM/ActiveX layer that is started by XLSREAD. In particular, Excel is not able to allocate enough memory when it attempts to copy large amounts of data for transfer into MATLAB, and MATLAB is re-throwing the error in the Command Window.
You may perform the following steps in order to eliminate the error:
- This error may occur if a file with macros is saved in Excel 2003 and then used with Excel 2007 or Excel 2010. The issue may be resolved by first opening the file with Excel 2007 or 2010 and re-saving.
- Place the Excel file in the local directory. If the file is on a shared network, it could be open in a program or in use by users. A possible workaround would be to change the location of the Excel workbook to a local directory from a mapped network drive.
- Run the Disk Cleanup by navigating to Start, type "Disk Cleanup" and remove only the "Temporary files" by checking only that option.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!