Execute files from listbox one by one
1 次查看(过去 30 天)
显示 更早的评论
GUI load some files using Pushbutton1 inside Listbox1. Now i have got another pushbutton2 to select all the files populated in listbox1. Now I would like to read all data from the files in listbox1 one by one. callback for pushbutton3 should be such that it should get all the filenames from _ listbox1_ and read it individually. Some how am not able to do it. Do i need callback for listbox1 as well?
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[filename,pathname,filterindex] = uigetfile('*.xls;*.xlsx;*.xlsm;*.xlsb', 'Multiselect', 'on');
set(handles.listboxExcelfiles,'string',filename);
% --- Executes on selection change in listbox1
function listbox1_Callback(hObject, eventdata, handles)
% Hints: contents = cellstr(get(hObject,'String')) returns listboxDatasheets contents as cell array
% contents{get(hObject,'Value')} returns selected item from listboxDatasheets
% --- Executes on button press in pushbutton2
function pushbutton2_Callback(hObject, eventdata, handles)
select_all = numel(get(handles.listboxExcelfiles,'string'));
set(handles.listboxExcelfiles,'value',1:select_all);
% --- Executes on button press in pushbutton3
function pushbutton3_Callback(hObject, eventdata, handles)
filename = get(handles.listbox1,'string'));
len = length(filename);
for j = 1 : len
[num,txt,raw] = xlsread(filename,10,'J10:J34');
set(handles.listbox2, 'string', num);
end
Also there could be overwriting in listbox2. How can i exclude value if there is a repetition in listbox2
3 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!