How to read excel data in app designer?
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/955975/image.jpeg)
0 commentaires
Réponse acceptée
Voss
le 10 Avr 2022
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
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!