xlsread can't find file but exist() can
3 views (last 30 days)
Show older comments
Running Matlab 2014a 64 bit on Windows 7.
Occasionally, when trying to open .xls files using xlsread I get the error:
XLSREAD unable to open file '\\path\subpath\...\filename.xls'. File '\\path\subpath\...\filename.xls'' not found.
the strings I'm using for pathname and filename are generated by using uigetfile, so Matlab can obviously see the files, which I've double checked using the exist function. I'm able to get around the problem by manually opening the Excel files and then closing them (Excel always prompts if I want to save, despite me changing nothing in the file), after which xlsread is successfully able to load the files.
These are .xls files containing macros
0 Comments
Answers (1)
Sean de Wolski
on 19 Dec 2014
Are you creating absolute full file paths with both outputs of uigetfile?
[FileName,PathName] = uigetfile()
fn = fullfile(PathName,FileName)
xlsread(fn)
Otherwise, it could be relative and not found if the current directory changes or similar.
0 Comments
See Also
Categories
Find more on Data Import from MATLAB 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!