Error importing excel table into app designer table
12 次查看(过去 30 天)
显示 更早的评论
Hi,
I am a beginner to MATLAB and making an application using App Designer. I have been working and haven't been able to find an answer online, but I am trying to get a button in my app so that; when the button is clicked, I can choose a excel(csv) file to display onto the UI table once chosen.
However, I am receiving the following error; Error setting property 'Data' of class 'Table': Values within a cell array must be numeric, logical, or char
Is there a problem with my code or is this an issue with my data set? My data set contains a mixture of integers, strings, date and time.
Below is my code for the callback on the button;
[filename, pathname] = uigetfile({'*.csv'},'File Selector');
fullpath = strcat(pathname,filename);
x = readtable(fullpath);
app.UITable.Data = table2cell(x);
Many Thanks for your help
4 个评论
Kojiro Saito
2018-10-3
Is it possible to provide your sample data? Because I've created a dummy csv file as the attached and it works without an error with your above codes. I think it's difficult to investigate why the error occurs without your sample data.
采纳的回答
Kojiro Saito
2018-10-5
In case of your Journals.csv, you don't need to use table2cell. Just setting a table as a value works.
x = readtable(fullpath);
app.UITable.Data = x;
% Change column name from imported data
app.UITable.ColumnName = x.Properties.VariableNames;
Result in App Designer.
4 个评论
KRISHNA PATIL
2021-10-13
Thank you Kojiro Saito today you made my day as I was looking for someting and got the exact what i want. can you please help me for standaloon application further more. waiting for your reply.
更多回答(1 个)
sarthak rawat
2018-12-21
error:"Struct contents reference from a non-struct array object."
comes in line "app.UITable.ColumnName = x.Properties.VariableNames"
please help!!
2 个评论
Kojiro Saito
2018-12-25
Could you give more detail information (codes or mlapp and csv data) to investigate why the error occurs, please?
Rubén García García
2020-4-18
function seleccionararchivoButtonPushed(app, event)
global archivo
[ filname, pathname ] = uigetfile({'*.xlsx'},'File Selector');
fullpathname = strcat(pathname,filname);
archivo = xlsread(fullpathname);
app.Label.Text = filname;
app.UITable.ColumnName = [{'Gb','Ta','Ta','Ts','Flujo'}];
app.UITable.Data = array2table(archivo);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!