How to read excel data in app designer?

60 visualizaciones (últimos 30 días)
Ali Deniz
Ali Deniz el 7 de Abr. de 2022
Comentada: Voss el 26 de Abr. de 2022
% 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

Respuesta aceptada

Voss
Voss el 10 de Abr. de 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 comentarios
Ali Deniz
Ali Deniz el 26 de Abr. de 2022
Thank you.
Voss
Voss el 26 de Abr. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by