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
96 ビュー (過去 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!