what cause this error to xlsread randomnly?

조회 수: 141 (최근 30일)
Dimitrios
Dimitrios 2014년 10월 10일
댓글: Srishti 2023년 7월 3일
I have a script where i load a excel file.Sometimes the file is not loaded and the following error is displayed:
Error using xlsread (line 247)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Open method of Workbooks class failed
Help File: xlmain11.chm
Help Context ID: 0
What i find strange is that if i run again the script the file is loaded normally without changing anything to the code.What could be the issue for that? Thanks in Advance
  댓글 수: 8
Image Analyst
Image Analyst 2021년 6월 5일
Last I checked, the length of a filename in Excel (folder + base file name) was limited to 218 characters.
Ranjith Madhana Gopal
Ranjith Madhana Gopal 2021년 6월 10일
편집: Ranjith Madhana Gopal 2021년 6월 10일
So yes, the character limit for the name of an excel file is 218, but it also includes the path name. So try the following below and your Excel/ windows explorer will not let you add more characters to the name the file. For example - only half of file name is present and it won't let me spell even length, let alone finish the rest of the name of the file.
D:\Research\2021\May\May 25th & May 26th\May 26th - Subject 1 - Left\Data\Left Hand\Index and Thumb\Range of Motion\Flexion-Extension\Up\Length Calculation trials\Trial 8 - Index and Thumb\Real_hand_left_Index_Thumb_Leng
Its got 220 characters. (Also, I see you've mentioned folder name) I've provided the example so that somebody with a similar problem may have reference.

댓글을 달려면 로그인하십시오.

답변 (5개)

Image Analyst
Image Analyst 2015년 5월 7일
Is Excel already open to that workbook when you try to do that? Before you call xlsread, type (if you're in Windows) control-shift-Esc and see if you see Excel in the Process list.

SAGAR SINGH RATHOR
SAGAR SINGH RATHOR 2018년 5월 31일
편집: SAGAR SINGH RATHOR 2018년 6월 13일
I just restarted my PC and the problem was solved or you can just restart the Matlab.
  댓글 수: 2
Hiral Panchal
Hiral Panchal 2021년 6월 27일
Restarting MATLAB worked. Thanks :)
Srishti
Srishti 2023년 7월 3일
Restarting matlab worked for me in 2023 matlab

댓글을 달려면 로그인하십시오.


Jeff
Jeff 2016년 3월 29일
편집: Jeff 2016년 3월 29일
I am currently getting the same error when just simply trying use xlsread on a .xlsx file and it doesn't appear to be related to any other instance of excel running.
I am currently on matlab version 2015a but when testing on 2014a the same file works without the above error. Any help would be greatly appreciated.
Error using xlsread (line 247) Invoke Error, Dispatch Exception: Source: Microsoft Excel Description: Goto method of Application class failed Help File: xlmain11.chm Help Context ID: 0

Chien-Han Su
Chien-Han Su 2021년 3월 24일
편집: Chien-Han Su 2021년 3월 24일
I encountered and solved this problem recently with Matlab2018a running on Win10.
At first I tried again after restarting my computer but it didn't work.
I then tried to directly open my original .xls file and happened to find that it was opened in Protected View Mode in Office 2010 Excel on my computer, also my Office 2010 authentication was overdue.
My guess was that xlsread() might failed if the file is under Protected View Mode though I'm not sure what the relation between matlab readxls() and the MS Office. Anyway, after re-authenticate my Office 2010, and make sure I can directly open my .xls file with Excel without entering Protected View Mode, Now my Matlab can excute xlsread() again.

Ranjith Madhana Gopal
Ranjith Madhana Gopal 2021년 6월 5일
I tried different methods, but the problem was rather trivial. - the name of the excel file, that I was trying to read was too long. So once I changed the name of the excel file the code was working just fine.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by