フィルターのクリア

How to read excel data in app designer?

44 ビュー (過去 30 日間)
Ali Deniz
Ali Deniz 2022 年 4 月 7 日
コメント済み: Voss 2022 年 4 月 26 日
% 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

採用された回答

Voss
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
  2 件のコメント
Ali Deniz
Ali Deniz 2022 年 4 月 26 日
Thank you.
Voss
Voss 2022 年 4 月 26 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by