Setting popup menu strings from excel

1 visualización (últimos 30 días)
adi kul
adi kul el 24 de Mzo. de 2017
Respondida: ES el 24 de Mzo. de 2017
I am reading the excel spreadsheet as follows:
function upload_Callback(hObject, eventdata, handles)
% hObject handle to upload (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject, handles);
[FileName1,PathName1] = uigetfile({'*.xls';'*.txt';'*.csv';'*.*'},'Select the text file that contains the data');
if isempty(FileName1)
errordlg('No file was selected that contains the data so the calculation was aborted.');
flag = true;
return
end
S3.selected_dir_upload =fullfile(PathName1,FileName1);
handles.S3.selected_dir_upload =S3.selected_dir_upload ;
[S3.num, S3.txt]=xlsread(S3.selected_dir_upload)
set(handles.upload_file, 'String', S3.selected_dir_upload)
set(handles.upload, 'UserData', S3);
After that I have a popup menu which should populate the texts from the excel sheet. For which I am trying this:
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
S3 = get(handles.upload, 'UserData');
set(handles.popupmenu1,'String',S3.txt);
But I am not able to get the list updated once the excel is read. Please suggest!

Respuesta aceptada

ES
ES el 24 de Mzo. de 2017
I think you should update the popupmenu string from upload call back itself.
This will update the data on the poupmenu once the file is uploaded.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by