How do I make a table in App Design pull data from multiple excel sheets from the same excel file?
8 次查看(过去 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!