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

18 ビュー (過去 30 日間)
Gabriel Aviles
Gabriel Aviles 2020 年 5 月 16 日
回答済み: Jyotsna Talluri 2020 年 5 月 19 日
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 件のコメント
Gabriel Aviles
Gabriel Aviles 2020 年 5 月 16 日
Could it be done the same way the array hCheckboxes was created ?
Rik
Rik 2020 年 5 月 17 日
Sure, although I would first check what syntax xlswrite needs. Then you can tailor the way you put it into an array to that.

サインインしてコメントする。

回答 (1 件)

Jyotsna Talluri
Jyotsna Talluri 2020 年 5 月 19 日
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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by