1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
function name_edit_Callback(hObject, eventdata, handles)
% hObject handle to name_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of name_edit as text
% str2double(get(hObject,'String')) returns contents of name_edit as a double
handles.metricdata.name_edit = get(hObject,'String');
nom =get(hObject,'String');
setappdata(0,'lenom',nom);
% --- Executes during object creation, after setting all properties.
function name_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to name_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ---Fonction qui retourne la plage de cellules utilisées dans la feuille courante d'un fichier xls--------------
function [minCol,minLigne,maxCol,maxLigne]=getcellsrange(xls)
if exist(xls,'file')~=2
error('Can''t read xls file');
end
Excel = actxserver( 'Excel.Application' );
invoke(Excel.Workbooks, 'open', xls);
DataRange = Excel.ActiveSheet.UsedRange;
DataRange.Address
[minCol,minLigne,maxCol,maxLigne]=strread(DataRange.Address(2:end),'%s%d:%s%d','delimiter','$')
invoke(Excel,'quit');
delete(Excel);
% --------------------------------------------------------------------
function Save_Menu_Callback(hObject, eventdata, handles)
h = questdlg(['Do you want to save the data ? '],...
['Save Data ' ],...
'Yes','No','Yes');
xls = 'C:\Documents and Settings\POSTE\Mes documents\MATLAB\Results.xls';
[minCol,minLigne,maxCol,maxLigne] = getcellsrange(xls);
tab= [minCol maxLigne+1];
range = sprintf('%s%d',tab);
if strcmp(h,'No')
return;
else
% max =str2double(get(handles.text11,'String'))
% for i=1:max
% stringA='A'
% stringB=10+(3*(i-1))
% string= strcat(stringA,int2str(stringB));
nom= getappdata(0,'lenom') ;
prenom= getappdata(0,'leprenom');
age= getappdata(0,'sonage');
duration= getappdata(0,'theduration');
sex= getappdata(0,'thesex');
d = {nom , prenom ,sex, age, duration};
% if i == 1
% c = d;
% else
% c = cat(1,c,d);
% end
%
% end
% s = xlswrite('Results.xls', c,'Data', string);
% max = max+1;
% set(handles.text11,'String',num2str(max));
s = xlswrite('Results.xls', d,'Data', range);
end |
Partager