필터 지우기
필터 지우기

Overwrite an existing excel file (multiple sheets)

조회 수: 7 (최근 30일)
Francesca Danielli
Francesca Danielli 2021년 12월 28일
댓글: Francesca Danielli 2021년 12월 29일
Hi everyone!
I have imported an Excel file with N=20 sheets.
Each sheet contains two coloumns.
I create two cell arrays, Cf, Ci in the figure.
The following figure shows how each cella array is made.
Finally, the following figure shows how each table is made (in particular, Var1 e Var2 of Ci correspond to the 2 coloumn of esch excel sheet).
I would like to:
  • add Var1 and Var2 of Cf to each table of Ci;
  • overwrite the existing excel file with the modified sheets --> each sheet will have two coloumn corresponding to Ci and two coloumns corresponding to Cf.
Do you have any suggestion?
Thank you in advance!
  댓글 수: 1
Stephen23
Stephen23 2021년 12월 28일
"Do you have any suggestion?"
Do NOT use the variable name DIR, because this will shadow the very important inbuilt DIR function.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2021년 12월 28일
You can call xlswrite() or writetable() one sheet at a time. It should add the new sheets and retain the existing sheets.
  댓글 수: 4
Francesca Danielli
Francesca Danielli 2021년 12월 29일
I tried :
for k = 1:N_sheet
xlswrite('filename.xlsx',Cf{k},'D1:E1')
end
but I obtained the following error message 'Input data must be a numeric, cell, or logical array.'
--------------------------------------------------------------------------------------------------------------------------------------------
Then, I tried
for k = 1:N_sheet
xlswrite('filename.xlsx',Cf,'D1:E1')
end
but nothing has been written in the Excel file
Francesca Danielli
Francesca Danielli 2021년 12월 29일
SOLVED! I found the error.
Thank you :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by