transferer une figure de matlab vers excel
bonjour,
Je voudrais récupérer une figure à partir de ma fenêtre GUI pour l'exporter vers un fichier excel.Pour l'instant, j'arrive à afficher une image mais celle-ci reprend toute la fenêtre gui et pas seulement la figure. Je voudrais donc récupérer seulement le figure.
Voici mon code:
Code:
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
| function pushbutton2_Callback(hObject, eventdata, handles,TestData, Motor, Drive, Comments)
%[TestData, Motor, Drive, Comments] = read_BENG_MotorTestbench;
watchon
drawnow
print -djpeg; %.................Copying to clipboard
FILE = 'C:\test_plot.xls';
Range ='A1';
%.............excel COM object............................................................................
Excel = actxserver ('Excel.Application');
Excel.Visible = 1;
if ~exist(FILE,'file')
ExcelWorkbook=Excel.Workbooks.Add;
ExcelWorkbook.SaveAs(FILE);
ExcelWorkbook.Close(false);
end
invoke(Excel.Workbooks,'Open',FILE); %Open the file
hFig = gcf
hgexport(hFig,'-clipboard')
ActiveSheet = Excel.ActiveSheet;
ActiveSheetRange = get(ActiveSheet,'Range',Range);
ActiveSheetRange.Select;
ActiveSheetRange.PasteSpecial; %.................Pasting the figure to the selected location
watchoff |
De plus, j'ai plusieurs figure à afficher et je voudrais en mettre une par sheet sur excel. Comment je peux séléctionner les différents sheets?
Merci