How can DropDown Items dynamically obtain the name of different sheets in Excel instead of manually entering items?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jie Wu
el 27 de Mzo. de 2022
Comentada: Jie Wu
el 28 de Mzo. de 2022
If the items of dropdown are the names of multiple sheets of Excel, how to write the callback function is that the items are not written in by themselves, but obtained by importing Excel to read different sheets,Who can help me solve this problem, write a callback function or send a template?
0 comentarios
Respuesta aceptada
Simon Chan
el 27 de Mzo. de 2022
When you import the file, get the sheet names and put them as the 'Items' of the uidropdown.
sheetName = sheetnames(fullfile(pathname,filename));
% dd = uidropdown(uif,'Items',{''},'Value',{''}); % Assume original is empty
set(dd,'Items',sheetName,'Value',sheetName(1))
3 comentarios
Simon Chan
el 28 de Mzo. de 2022
Suppose your data in the excel sheets are all numeric data, you can use function readmatrix:
%uit = uitable(uif) % Don't know your uitable configuration
uit.Data = readmatrix(fullfile(pathname,filename),'Sheet',dd.Value); % Read the sheet choosen from the uidropdown
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!