copying the excel data to uitable

17 ビュー (過去 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 Center および File ExchangeDevelop 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