Upload excel data to uitable

조회 수: 4 (최근 30일)
Daniel Kin
Daniel Kin 2013년 4월 9일
댓글: Malte Räuchle 2020년 7월 23일
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