Upload excel data to uitable

4 vues (au cours des 30 derniers jours)
Daniel Kin
Daniel Kin le 9 Avr 2013
Commenté : Malte Räuchle le 23 Juil 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 commentaire
Daniel Kin
Daniel Kin le 10 Avr 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);

Connectez-vous pour commenter.

Réponses (1)

brigitte duran
brigitte duran le 14 Avr 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 commentaire
Malte Räuchle
Malte Räuchle le 23 Juil 2020
Is it possible that your Excel File contains any other type than numeric array, logical array, or cell array?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by