How to open file with xlsread?

6 views (last 30 days)
Nicole
Nicole on 2 May 2014
Answered: Evan Wang on 28 Jul 2015
Hi all, I'm trying to make a scatter plot for a lot of data, but I can't even get the file to load (I'm a novice MATLAB user).
My error with xlsread is saying:
Error using xlsread (line 247)
Could not open file
/private/tmp/tp6d2f946e_fe42_4be4_8e2c_5b1129986b25/docProps/app.xml. No such
file or directory.
Here is my code:
clear all;
data = 'chr2-subj-fits-humanaud.xlsx';
y = xlsread (data, 'E126:E161');
I even tried this code in order to select the file but I'm still getting the same error.
[fname,fpath] = uigetfile({'chr2-subj-fits-humanaud.xlsx'});
if fpath==0, error('no file selected'); end
[num,txt,raw] = xlsread( fullfile(fpath,fname) );
Thanks, Nicole
  3 Comments
Geoff Hayes
Geoff Hayes on 2 May 2014
Hi Nicole - you have the correct command line inputs into the xlsread command so that should be fine. The missing file (docProps/app.xml) seems to be something specific to Excel (and maybe other MS products like Word). I was able to read in data from my own Excel file on a computer that doesn't have Excel and was able to do so just fine (so there was no dependency on the docProps/app.xml for me).
What version of Excel has the file been saved to? Could you try another (2007) to see what happens?
Or try running your command with an additional parameter (and empty string):
y = xlsread (data, '','E126:E161','basic');
According to matlab xlsread, the basic directive is set so that the command:
reads data from the spreadsheet in basic mode, the default on systems without Excel for Windows. If you do not specify all the arguments, use empty strings as placeholders, for example, num = xlsread(filename,'','','basic').
As per the above, I added an empty string into the command for you to try.
Actually, it will only mean something if you are running MATLAB on a PC. If not, then basic seems to be the default setting (it is on my Mac).
Geoff
Image Analyst
Image Analyst on 3 May 2014
Please attach that file. Is it just that particular file, or do you get the same error message for ALL files?

Sign in to comment.

Answers (2)

Ken Atwell
Ken Atwell on 4 May 2014
This is an error in MATLAB's internal processing of the file. I can tell from the error that you are almost certainly running a newish version of MATLAB that can read XLSX files without Excel, and you are probably running on a Mac. Here are some ideas and further questions:
  1. First, try to load the file in Excel. Does is load correctly? Was the file created with Excel, or Open Office or some other Excel-compatible software?
  2. Try not specifying a range (that is, leave off the second argument)
  3. If any of the sheet names in the spreadsheet contain non-ASCII characters, try modifying them to have only letters (specifically, the 26 letters in the English alphabet), numbers, and spaces.
If none of this helps, tell us more about your version of MATLAB, Excel, and operating system, and attach the file as Image Analyst suggests.

Evan Wang
Evan Wang on 28 Jul 2015
I have experienced similar issue. When I was running Matlab2012, my code got data from a worksheet in Excel perfectly. After updating my version to 2015, when I ran the code again for some reason, it couldn't find the worksheet.

Tags

Community Treasure Hunt

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

Start Hunting!