xlsread Error: Object returned error code: 0x800A03EC

14 次查看(过去 30 天)
Good morning,
I know there are a few questions already answered on this topic, but my problem is a little different and I've tried all the possible solutions given in those threads.
I am using Matlab R2020b, which should be the latest version. I wrote a script months ago which was using xlsread to read from excel spreadsheets that were in the csv format. That worked good and i managed to import all data and make all the analysis. After months I re-opened the file and run it. This is the error it gives me:
Error using xlsread (line 257)
Error: Object returned error code: 0x800A03EC
and the code is
files=dir('C:\Users\Name\Folder1\Folder2\Folder3\*.csv'); % Identifies the .csv files of the specified folder
for i=1:sum(~cellfun(@isempty,{files.name}))
[~, ~, excel{i}]=xlsread(fullfile(files(i).folder,files(i).name));
parameters{i} = excel{i}(1,:);
namestruct{i}=strcat('M',files(i).name(1:end-4));
data.(namestruct{i}) = cell2mat(excel{i}(2:end,:));
end
I want to specify that nothing has changed, neither the extension of Excel files, nor the Matlab version. I also tried to use the function in a much more simpler script, where excel file was just a column and placed in the same folder as the script, and without a for loop.
I also know that is now advised to use readtable function, but I have ten different scripts that uses xlswrite function which was very useful for me and I don't want to change them.
Does anybody know why this function is not working anymore for me?

采纳的回答

Maadhav Akula
Maadhav Akula 2020-11-20
Hi Anna,
"xlsread" communicates with an Excel COM automation server. Communicating with COM is not 100% reliable. The error message means that there are some issue during communicating with COM and it is difficult to debug.
This is one of the reason that we recommend using "readtable" or "readmatrix" because these two functions will default to NOT using a COM server to read Excel files.
Hope this helps!
  2 个评论
Anna Maria Soriani
Anna Maria Soriani 2020-11-23
编辑:Anna Maria Soriani 2020-11-23
Thank you very much. I understand, but just out of curiosity why that function was working and then after months it is having this kind of problem of communication? Does this happens when something on MS Excel changed, like maybe I upgraded it or something? Even though I am pretty sure I didn't modify anything.
Thank you again, I will avoid this function from now on and rewrite the codes I have.
Adam Head
Adam Head 2021-1-14
Hi Maadhav,
I have the same problem. Your answer was not a solution, i'm afraid. I also use xlsread in my code. It was working a few months back and now it is not. I also think this is because of an update/ change in Matlab's functions or Microsoft Office. I would need a better explanation than to "use another function".
If you don't have a troublshooting option then I will go through the university channels.
Thanks,
Adam

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by