简体   繁体   中英

Read data from excel to table in MATLAB App Designer

Good evening I am trying to develop a MATLAB GUI where the user can either input the data manually in a table or attach an excel folder, which will copy the data in the excel sheet in the table.My lines of code are

function AttachExcelFolderButtonPushed(app, event)
            [filename pathname]=uigetfile({'*.xlsx'},'File Selector');
            text = readtable(filename, "Sheet",1);
            app.UITable.Data = text;
        end

I get the following error:

Error using readtable (line 223) Unable to open file 'Book1.xlsx' as a workbook. Check that the file exists, read access is available, and the file is a valid spreadsheet file.

Please help Note: I am a newbie Thank you

My guess is that you don't have the file you want on the path. Try this line:

text = readtable([pathnaem filename], "Sheet",1);

This will use the entire path of the file to find it. Otherwise MATLAB will only look for files currently on the path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM