xlsread Error: MATLAB:COM:E2148140012

11 次查看(过去 30 天)
I'm getting the following error when trying to use xlsread in Matlab 2018b:
Error using xlsread (line 257)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Open method of Workbooks class failed
Help File: xlmain11.chm
Help Context ID: 0
I was able to catch this exception and get the following information from it as well:
id =
'MATLAB:COM:E2148140012'
cause =
0×1 empty cell array
I'm confused why I'm getting this error because I call xlsread here multiple times (in a loop) before the error gets thrown. I've taken the following steps already to try and fix the error, and none have worked yet:
  • Unchecked "Ignore other applications that use Dynamic Data Exchange (DDE)" in Microsoft Excel 2013
  • Reset file associations in Excel 2013
  • Turned off add-ins in Excel 2013
  • Disabled hardware acceleration in Excel 2013
  • Ended all Excel processes in Task Manager and re-ran script. Fails at same point.
  • Restarted Matlab
  • Restarted Excel
  • Tried running in Matlab 2019b, same error
What causes this error, and what else can I do to fix it?

回答(1 个)

Harshendra Shah
Harshendra Shah 2020-4-9
The reason behind this issue can be the call from MATLAB to Excel to read an Excel file using COM component failed and Excel was not able to read the file Successfully. One of the possible reason behind this issue is that the Excel file you are trying to read is corrupted. Please make sure that the file can be opened and viewed from outside of MATLAB using Microsoft Excel, before reading it using "xlsread".
This error message can also be thrown because of 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 can try performing the following steps and check if the error gets eliminated or not:
1) This error may occur if a file with macros is saved in Excel 2003 and then used with Excel 2007, Excel 2010 or Excel 2013. The issue may be resolved by first opening the file with Excel 2007, 2010 or 2013 and re-saving.
2) 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.
3) Run the Disk Cleanup by navigating to Start, type "Disk Cleanup" and remove only the "Temporary files" by checking only that option.
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by