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
조회 수: 86 (최근 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!