readmatrix issue with multiple sheet excel
6 views (last 30 days)
Show older comments
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,
0 Comments
Answers (1)
Walter Roberson
on 13 Nov 2020
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.
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!