How to import excel data into table GUI matlab

Hi. I just knew Matlab.
I want to make a simple project that displays data in the GUI table after I press the browse button and
I'm having trouble importing this data from Excel into the GUI table. the excel data that I imported is not visible in the GUI table.
Could you help me correct my code for that? Thank you very much!
this is my code:
% --- Executes on button press in btnBrowse.
function btnBrowse_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
[namafile,direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file Excel');
alamatfile=fullfile(direktori,namafile);
set(handles.btnBrowse,'String','alamatfile');
[a,b,c]=xlsread(alamatfile);
bar=size(c,1);
col=size(c,2);
rnames=linspace(1,bar,bar);
data=c(:,1:col)
set(handles.tabel1,'Userdata',data);
guidata(hObject,handles);

5 comentarios

Rik
Rik el 16 de Jun. de 2020
[removed from spam filter]
Mohammad Sami
Mohammad Sami el 16 de Jun. de 2020
You need to set the 'Data' property rather than 'UserData' property.
inggrid kinanti
inggrid kinanti el 16 de Jun. de 2020
You are right, thank you so much !!
But may i know why I have to set the 'Data' property rather than the 'UserData' property ?
Andrei Smoliakov
Andrei Smoliakov el 17 de Jun. de 2020
That's because 'UserData' property is used not for table content, but for any custom user data associated with it. It can be used, for example, to share data between functions. For the displayed table content 'Data' property is used. You can read more about it in the "Table Properties" documentation page.
inggrid kinanti
inggrid kinanti el 18 de Jun. de 2020
Thank you so much andrey, you helped me understand

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 16 de Jun. de 2020

Comentada:

el 18 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by