필터 지우기
필터 지우기

Setting popup menu strings from excel

조회 수: 1 (최근 30일)
adi kul
adi kul 2017년 3월 24일
답변: ES 2017년 3월 24일
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!

채택된 답변

ES
ES 2017년 3월 24일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by