copying the excel data to uitable

조회 수: 14 (최근 30일)
kodishwaran S
kodishwaran S 2015년 10월 19일
댓글: kodishwaran S 2015년 10월 27일
I am new to Matlab, I am having some trouble, I have loaded the excel data using push button and I want to update the data in uitable by selecting the column headers updated in the popup menu, the column names are added in the popup menu by using this code.
function pushbutton_Load_data_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Load_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
filename=uigetfile({'*.xls';'*.csv'});
handles.filename=filename;
guidata(hObject, handles);
setpopupmenuString(handles.popupmenuA,eventdata,handles)
setpopupmenuString(handles.popupmenuB,eventdata,handles)
function setpopupmenuString(hObject,eventdata,handles)
filename=handles.filename;
[numbers,colNames]=xlsread(filename);
set(hObject,'String',colNames(1,:));
class(colNames)
size(colNames)
colNames{1,1}
now my problem is, trying to load the update the data in uitable under its respective column name by selecting the column name in popup menu. please help me to solve this issue.
  댓글 수: 2
TastyPastry
TastyPastry 2015년 10월 19일
A few clarification questions:
You're loading a spreadsheet with column headers. Do they match your uitable() headers?
Does your popup menu allow the user to select to load the data into any of the columns?
Does the popup menu contain all the columns of your uitable()?
kodishwaran S
kodishwaran S 2015년 10월 27일
For uploading the data in a spreadsheet directly to the uitable I am using this code,
[data,colNames,rowNames]=xlsread(filename);
columnwidth = {'auto'};
columneditable = [true];
set(handles.uitable1,'Data',data,'ColumnName',colNames(1,:),'RowName',rowNames(2:end,1),'ColumnWidth',columnwidth,'ColumnEditable', columneditable);
But in my case, I want to upload the data by selecting the specific columns with the help of popup menu. All the column names were update in the popup menu drop down list by using the previous code.
Kindly help me to achieve it.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by