How to read excel data in app designer?

조회 수: 13 (최근 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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by