readmatrix issue with multiple sheet excel

조회 수: 6 (최근 30일)
Ignacio Ballesteros Ruiz
Ignacio Ballesteros Ruiz 2020년 11월 12일
답변: Walter Roberson 2020년 11월 13일
Hi,
I am using readmatrix to access data that is stored in an Excel file. This excel file has two sheets, so I am using the following comand to access it:
SF_Data = readmatrix('LMS_Corrected','UseExcel',1,'Sheet',2);
However when I run the code it sometimes fails in this line and the console outputs the following message:
[spreadsheet_err]: Could not parse
a valid range from the given
string. A valid range is of the
form 'A1' (cell), 'A:B'
(column-select), '1:5' (row-select)
or 'A1:B5' (rectangle-select).
It fails randomly, sometimes the code will work, sometimes it will get stuck here. I have found a way around it which is to print a variable after that line, or to write that line again, without changing anything, at it works (for a couple of runs, then it will fail again). Any reason why this might be happening?
I have also tried to change the 'Sheet' parameter to the name of the sheet instead of its number, but the issue remains.
Thank you,

답변 (1개)

Walter Roberson
Walter Roberson 2020년 11월 13일
My suspicion about what is happening is that the Excel process is busy. Sometimes you have to pause() briefly... sometimes up to 5 seconds but usually less... for Excel to finish what it is doing, if you are doing several Excel operations in a row.
The way to avoid that would be to 'UseExcel', 0 so that it never talks to Excel at all.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by