How do I make a table in App Design pull data from multiple excel sheets from the same excel file?
조회 수: 4 (최근 30일)
이전 댓글 표시
I need a sequence of code that can be used to pull data from different sheets all in the same file, or from different files in general. Currently, using:
t = readtable(value)
app.UITable.Data = t
Only displays one set of data, no matter how many different variables I try to insert.
What am I doing wrong? How do I get the Edit Field to display different data from different excel sheets, all originating from the same file?
Thank you
댓글 수: 0
답변 (1개)
Monika Phadnis
2020년 5월 13일
For saving data from multiple files to same file
You can read from different files using 'readtable' function into different variables, and then save those variables into a '.mat' file using 'save' function.
Then, load the variables to use them.
For example,
var1 = readtable('file1');
var2 = readtable('file2');
save('matFilename','var1','var2'); % saving the variables to mat file with the specified name
Display different tables on changing values in EditField
Example code for EditField callback function
function EditFieldValueChanged(app, event)
value = app.EditField.Value;
load matFilename var1 var2;
if value == 1 % you can add options of your choice
app.UITable.Data = var1; % assign the table data to UITable object
elseif value == 2
app.UITable.Data = var2;
end
end
This is example code for two files. You can change it accordingly.
Hope it helps.
댓글 수: 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!