Create multiple excel sheet using loop and rename them using loop
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Venkatesh Jalnapure
am 10 Dez. 2020
Beantwortet: Mathieu NOE
am 10 Dez. 2020
Hi All,
Kindly help me to create the multiple excel sheets in single workbook and rename them using the loop.
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 10 Dez. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!