without writing any data, I want to create blank excel file.

36 visualizzazioni (ultimi 30 giorni)
Hello
Initially, I want to create new excel file in a desired location.
Later I will copy some of the sheets from Existing Excel i.e., 'oldExcel to 'newExcel'
excelFile1 = strcat(aaa,'.xlsx'); --------->here I am expecting to create New Blank Excel file (strcat is just written, no meaning)
excelName1 = fullfile(newPath,excelFile1); -----> newPath is already been defined in code
excel = actxserver('Excel.Application');
Workbooks = excel.Workbooks;
wbsource = Workbooks.Open(excelName); ----->excelName will be oldExcel
wbdest = Workbooks.Open(excelName1);
ws = wbsource.Worksheets.Item(newidx); ----->newidx will be having sheet name
ws.Copy(wdest.Worksheets.Item(1)); ----> trying to copy worksheet one after another... suggest here as well
wbdest.Save
Thank you

Risposta accettata

KSSV
KSSV il 3 Ago 2022
T = table ; % create empty table
fname = 'test.xlsx' ; % here you can give path as well
writetable(T,fname) ; % create a excel file with empty table
% LEts add sheets
for i = 1:5
% make your table to write
x = rand(3,1) ; y = rand(3,1) ;
T = table(x,y) ;
% now write table into sheets
writetable(T,fname,'Sheet',i)
end
  2 Commenti
Nisarga
Nisarga il 9 Mar 2024
It shows no error but it contains value in excel sheet
can we delete the values in the sheet

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by