Upload excel data to uitable

4 visualizaciones (últimos 30 días)
Daniel Kin
Daniel Kin el 9 de Abr. de 2013
Comentada: Malte Räuchle el 23 de Jul. de 2020
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 comentario
Daniel Kin
Daniel Kin el 10 de Abr. de 2013
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);

Iniciar sesión para comentar.

Respuestas (1)

brigitte duran
brigitte duran el 14 de Abr. de 2016
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 comentario
Malte Räuchle
Malte Räuchle el 23 de Jul. de 2020
Is it possible that your Excel File contains any other type than numeric array, logical array, or cell array?

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by