简体   繁体   English

从 excel 读取数据到 MATLAB App Designer 中的表

[英]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.晚上好,我正在尝试开发 MATLAB GUI,用户可以在表格中手动输入数据或附加 excel 文件夹,该文件夹将复制表格中 excel 表中的数据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.使用 readtable 时出错(第 223 行)无法将文件“Book1.xlsx”作为工作簿打开。 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.否则 MATLAB 将只查找当前路径上的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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