Create multiple excel sheet using loop and rename them using loop

Hi All,
Kindly help me to create the multiple excel sheets in single workbook and rename them using the loop.

 채택된 답변

Mathieu NOE
Mathieu NOE 2020년 12월 10일
hello
this is my suggestion :
VariableNames = {'Customer','x','y','d'};
SheetNames = {'A','B','C','D'};
filename_out = 'test.xlsx';
for hh = 1:numel(SheetNames)
% export to excel
data = rand(100,numel(VariableNames));
writecell(VariableNames,filename_out,"Sheet" ,char(SheetNames(hh)),"Range",'A1'); % save column headers in first line
writematrix(data,filename_out,"Sheet" ,char(SheetNames(hh)),"Range",'A2'); % save data (cell) to excel file
end

추가 답변 (0개)

카테고리

태그

질문:

2020년 12월 10일

답변:

2020년 12월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by