How to overwrite an excel file, matlab 2018?

조회 수: 5 (최근 30일)
Muazma Ali
Muazma Ali 2023년 12월 25일
댓글: Muazma Ali 2023년 12월 25일
I need to overwrite an excel file each time write table function runs but I don’t have Matlab 2020. And I cannot delete the file as I am later using it to be uploaded in my app for creating a table in my app.
How can I solve the problem
  댓글 수: 4
Image Analyst
Image Analyst 2023년 12월 25일
Then just call the writetable function over and over again. It will overwrite the existing file.
Muazma Ali
Muazma Ali 2023년 12월 25일
@Image Analystcan you please come up with an example?:)

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

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 12월 25일
Here is one code if understood your question correctly:
FName = 'Renew_Table.xlsx';
D = array2table(randi(255, 7, 3))
D = 7×3 table
Var1 Var2 Var3 ____ ____ ____ 253 86 140 111 16 208 12 135 161 91 74 185 25 158 122 252 253 83 71 101 77
writetable(D,FName,'Sheet',1);
for ii=1:3
D = readtable(FName);
D{:,:} = D{:,:}*ii;
writetable(D,FName,'Sheet',1);
end
D = readtable(FName)
D = 7×3 table
Var1 Var2 Var3 ____ ____ ____ 1518 516 840 666 96 1248 72 810 966 546 444 1110 150 948 732 1512 1518 498 426 606 462
  댓글 수: 1
Muazma Ali
Muazma Ali 2023년 12월 25일
@Sulaymon Eshkabilov I dont really understand what you are doing here; I dont think I can apply this as I have both number and text as part of my table

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

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by