set(handles.upload) is a problem and set(handles.uitable2,'Data', data) as well. Thanks for your help.
How can I edit my Excel data in a UItable Gui?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello, I want read my excel (spreadsheet)to import data and display this data in my uitable of my GUI. I ,write the code following and it doesn't work:
% --- Executes when entered data in editable cell(s) in uitable2.
function uitable2_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable2 (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'},'FluidesAnnulaires');
filename = strcat(path,file);
set(handles.upload);
data = xlsread(filename);
set(handles.uitable2,'Data',data)
Réponses (1)
Orion
le 14 Avr 2016
Hi,
For what I see your callback is not at a proper place.
The CellEditCallback is called when you modify manually the content of a uitable.
For now, I guess you should let this callback empty and create a pushbutton to get and load your data and insert it in the uitable.
something like
function uitable2_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% 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)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file,path] = uigetfile({'*.xls;*.xlsx','Excel Files'},'FluidesAnnulaires');
filename = fullfile(path,file);
data = xlsread(filename);
set(handles.uitable2,'Data',data)
0 commentaires
Voir également
Catégories
En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!