Upload excel data to uitable

4 次查看(过去 30 天)
Daniel Kin
Daniel Kin 2013-4-9
I wish to create a push button that read an excel file (always 7 columns) and transfer its contact to a uitable (with 7 columns), include showing the data in the uitable. I was thinking and looking for a solution how to so without success. Can it be done?
function readData_Callback(hObject, eventdata, handles)
handles.output = hObject;
[file,path] = uigetfile({'*.xls;*.xlsx','Excel Files'},' Select data file')
filename = strcat(path,file);
set(handles.readData);
data = xlsread(filename);
  1 个评论
Daniel Kin
Daniel Kin 2013-4-10
Solved it:
function readData_Callback(hObject, eventdata, handles)
% hObject handle to readData (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;
[file,path] = uigetfile({'*.xls;*.xlsx','Excel Files'},' Select data file')
filename = strcat(path,file);
set(handles.readData);
data = xlsread(filename);
data(:,[1 7])
set(handles.uitableData, 'Data',data);

请先登录,再进行评论。

回答(1 个)

brigitte duran
brigitte duran 2016-4-14
hello, sorry but your code doesn't work...I am looking for a solution but without success...My code is: In my GUI file.m:
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see UITABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
% handles.output = hObject;
[file,path] = uigetfile({'*.xls;*.xlsx','Excel Files'},'FluidesInternes');
filename = strcat(path,file);
%set(handles.upload);
data = xlsread(filename);
set(handles.uitable1,'Data',data)
  1 个评论
Malte Räuchle
Malte Räuchle 2020-7-23
Is it possible that your Excel File contains any other type than numeric array, logical array, or cell array?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by