Matlab automatycznie zapisuje plik Excela przy użyciu interfejsu ActiveX
Mam kod w matlab. Po uruchomieniu mojego programu został utworzony plik „example2.xlsx”.
Teraz mam poniższy kod i chcę, aby matlab zastąpił obecny „example2.xlsx” nowym „example2.xlsx” (zapisywanie automatyczne bez pytania mnie, czy chcę go zastąpić):
<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>