How do I make a table in App Design pull data from multiple excel sheets from the same excel file?

4 visualizaciones (últimos 30 días)
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

Respuestas (1)

Monika Phadnis
Monika Phadnis el 13 de Mayo de 2020
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.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by