2 pièce(s) jointe(s)
Copier une figure via MATLAB dans Excel
Bonjour tout le monde,
j'ai le même problème que dans cette discussion Copier une figure Matlab dans un fichier Excel
J'ai justement utilise le code proposé pour copier une figure via MatLab dans Excel.
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 31 32 33
| %% Send the picture in Excel
%Create Excelsheet for the figure
P={'Way of the flies'};
xlswrite(Filename,P,'Way','E1') % Create ExcelSheet
%Copy the figure
print -dmeta; %.................Copying to clipboard
%destination of the Excelfile
FILE=(strcat('C:\Users\Virtual\Desktop\Y-Maze (Maxime Gerday)\Labview Y-mase Maxime Gerday\Matlab\',num2str(Filename)))
%.............excel COM object.........................................
Excel = actxserver ('Excel.Application');
Excel.Visible = 0;
if ~exist(FILE,'file')
ExcelWorkbook=Excel.Workbooks.Add;
ExcelWorkbook.SaveAs(FILE);
ExcelWorkbook.Close(false);
end
invoke(Excel.Workbooks,'Open',FILE); %Open the file
Sheets = Excel.ActiveWorkBook.Sheets;
sheet_1 = get(Sheets, 'Item','Way');%select sheet
sheet_1.Activate
ActiveSheet = Excel.ActiveSheet;
ActiveSheetRange = get(ActiveSheet,'Range','A2');%select case
ActiveSheetRange.Select;
ActiveSheetRange.PasteSpecial;%Pasting the figure to the selected location
%-----------------------------------end of function"PlotInExcel-------------------------------------- |
Le probleme c`est qu`apres mon Excel est bon, pas de souci niveau collage, etc. Sauf quand j`ouvre le fichier, j`ai ce message.
Pièce jointe 177796
Et effectivement on voit qu`apres avoir runner le MatLab script un fichier Excel est toujours ouvert.
Pièce jointe 177797
C`est un probleme pour moi, je voudrais directement etre capable de faire couper/coller demon fichier Excel. Mais dans mon cas, je dois l`ouvrir dire non, fermer et sauver et seulement apres je peux couper/coller
J`avoue que cette partie de mon code, je l`ai juste copier, je la comprend pas tout a fait. donc je ne vois pas ou se situe le probleme.
SI quelqu`un a la solution, je le remercie d`avance ^^