Hello everybody,
I would like to export data to an excel file.
I import data from two different excel files and I want to export the results into one. The data which I want to export looks like this:
x -> 1000x2 double
y -> 1000x2 double
Now I want to create an excel file, with two sheets.
Sheet 1 = x(:,1) and y(:,1) -> Name of imported file #01
Sheet 2 = x(:,2) and y(:,2) -> Name of imported file #02
My code looks like this right now, but I'm not able to make it fully working:
for i=1:numel(Filename)
data(i)= {[x(:,i) y(:,i)]};
sheet(i)=cell2mat(Filename(1,i));
end
filename = ['Results.xlsx'];
Variable_names={'x','y'};
units={'mm', 'mm'};
A={Variable_names;
units;
data};
xlswrite(filename,A,sheet);
excelFileName = 'Results.xlsx';
excelFilePath = pwd;
sheetName = 'Sheet';
objExcel = actxserver('Excel.Application');
objExcel.Workbooks.Open(fullfile(excelFilePath, excelFileName));
try
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '1']).Delete;
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '2']).Delete;
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '3']).Delete;
catch
;
end
objExcel.ActiveWorkbook.Save;
objExcel.ActiveWorkbook.Close;
objExcel.Quit;
objExcel.delete;
Thank you for any advice
Cheers
Christian