copying the excel data to uitable

17 visualizaciones (últimos 30 días)
kodishwaran S
kodishwaran S el 19 de Oct. de 2015
Comentada: kodishwaran S el 27 de Oct. de 2015
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 comentarios
TastyPastry
TastyPastry el 19 de Oct. de 2015
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 el 27 de Oct. de 2015
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by