How can DropDown Items dynamically obtain the name of different sheets in Excel instead of manually entering items?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jie Wu
am 27 Mär. 2022
Kommentiert: Jie Wu
am 28 Mär. 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 Kommentare
Akzeptierte Antwort
Simon Chan
am 27 Mär. 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 Kommentare
Simon Chan
am 28 Mär. 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!