How can I export data to excel from a GUI (created using GUIDE) using a push button

7 views (last 30 days)
I use the pushbutton to collect the data entered in each element of the GUI. I want to export the data to excel when i press the pushbutton
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)
hCheckboxes= [handles.checkbox19 ; handles.checkbox20 ; handles.checkbox21 ;handles.checkbox22;...
handles.checkbox23 ; handles.checkbox24 ];
checkboxValues = get(hCheckboxes, 'Value')
cough = get(handles.chCough, 'Value');
dry_cough = get(handles.chDryCough, 'Value');
head_ache = get(handles.chHeadache, 'Value');
sore_throat = get(handles.chSoreThroat, 'Value');
chill = get(handles.chCFever, 'Value');
mild_fever = get(handles.chFever, 'Value');
severe_fever = get(handles.chSFever, 'Value');
loss_smelltaste = get(handles.chLST, 'Value');
shrotness_breath = get(handles.chShBreath, 'Value');
muscular_ache = get(handles.chMuscular, 'Value');
others = get(handles.chOthers, 'Value');
city = get(handles.chCity, 'String
name = get(handles.edit2, 'String')
lastname = get(handles.edit7, 'String');
age = get(handles.edit3, 'String')
info_adicional = get(handles.edit5, 'String');
  4 Comments
Rik
Rik on 17 May 2020
Sure, although I would first check what syntax xlswrite needs. Then you can tailor the way you put it into an array to that.

Sign in to comment.

Answers (1)

Jyotsna Talluri
Jyotsna Talluri on 19 May 2020
Create a cell array of all the variables and export the cell array to excel file which is created in the same directory using xlswrite.
arr = {cough,dry_cough,head_ache,sore_throat,chill,mild_fever,severe_fever,...};
xlswrite('new.xlsx',arr);
Refer to the below link for more inormation

Community Treasure Hunt

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

Start Hunting!