How to read excel data in app designer?
13 次查看(过去 30 天)
显示 更早的评论
% Button pushed function: Button
function ButtonPushed(app, event)
t = readtable("Kitap1.xlsx","Sheet",1);
app.UITable.Data = t;
app.UITable.ColumnName = t.Properties.VariableNames;
end
% Button pushed function: Button2
function Button2Pushed(app, event)
t=readtable("Kitap1.xlsx",);
app.UITable.Data = t;
app.UITable.ColumnName = t.Properties.VariableNames;,
I want to read the datas in the excel file specifically. I can read the all excel file when I pushed the "Button". But I want to read for example "Guidance" column in the photo. When I write the "Semi-Active" to the "Guidance" text area and the push the "Button2" I want to see Systems only have Semi-Active Guidance. How can I do it? Thank you
0 个评论
采纳的回答
Voss
2022-4-10
function ButtonPushed(app, event)
t = readtable("Kitap1.xlsx","Sheet",1);
app.UITable.Data = t;
app.UITable.ColumnName = t.Properties.VariableNames;
end
function Button2Pushed(app, event)
% read the xlsx file again (you could store this table t as a
% property of your app - do so in ButtonPushed - to avoid
% having to read it again here):
t = readtable("Kitap1.xlsx","Sheet",1);
% get just the rows of t where Guidance is whatever you typed
% in the "Guidance" uitextarea (here "textarea1" should be
% replaced by whatever the Guidance uitextarea is called in
% your app):
% e.g., match 'Semi-Active' exactly:
t = t(strcmp(t.Guidance,app.textarea1.Value),:);
% or match rows whose Guidance starts with 'Semi-Active'
% (for instance):
t = t(startsWith(t.Guidance,app.textarea1.Value),:);
% update the UITable with those rows:
app.UITable.Data = t;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!