matlab speichert Excel-Dateien automatisch über die ActiveX-Oberfläche
Ich habe einen Code in Matlab. Nachdem ich mein Programm ausgeführt habe, wurde eine Datei 'example2.xlsx' erstellt.
Jetzt habe ich den folgenden Code und möchte, dass matlab die aktuelle 'example2.xlsx' durch die neue 'example2.xlsx' ersetzt (automatisch speichern, ohne mich zu fragen, ob ich sie ersetzen möchte):
<code>e = actxserver ('Excel.Application'); % # open Activex server filename = fullfile(pwd,'example2.xlsx'); % # full path required ewb = e.Workbooks.Open(filename); % # open the file esh = ewb.ActiveSheet; str = num2str(num_rows+1); esh.Range(strcat('J',str)).Interior.Color = clr; sheet1 = e.Worksheets.get('Item', 'Sheet1'); range1 = get(sheet1,'Range', strcat('A',str),strcat('I',str)); range1.Value = values{num_rows+1}; [num, txt, raw] = xlsread('example2.xlsx'); num_rows = length(num(:,1)); xlWorkbookDefault = 51; % # it's the Excel constant, not sure how to pass it other way ewb.SaveAs(fullfile(pwd,'example2'), xlWorkbookDefault) ewb.Close(false) e.Quit e.delete </code>