Effacer les filtres
Effacer les filtres

Setting popup menu strings from excel

1 vue (au cours des 30 derniers jours)
adi kul
adi kul le 24 Mar 2017
Réponse apportée : ES le 24 Mar 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!

Réponse acceptée

ES
ES le 24 Mar 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.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by