Read and write data to an open excel file.

조회 수: 142 (최근 30일)
Saidi Chawki
Saidi Chawki 2022년 4월 13일
답변: John Bishop 2024년 1월 23일
Hello everyone, I need to ask how matlab R2017b can read data from an open excel file than write the data to the same file ? Because now it can't run without close the file.
Thank you !

답변 (2개)

Emmanuel J Rodriguez
Emmanuel J Rodriguez 2022년 4월 13일
  댓글 수: 8
Emmanuel J Rodriguez
Emmanuel J Rodriguez 2022년 4월 26일
Also, make sure all MS Excel instances are closed before executing the code.
Saidi Chawki
Saidi Chawki 2022년 5월 4일
Thank you for your help, I have tried it and it works well. There was a problem in my machine.

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


John Bishop
John Bishop 2024년 1월 23일
A simple workaround method that might work for some is to make a local temporary copy of the open file and work on that, then copy it back to the original when ready. It is also a safe method of working as it would not touch the original data until told to do so.
The 'system' command can run an OS command, e.g. on a MS Windows machine:
originalfilename='Book1.xlsx';
tempfilename='tmp.xlsx';
system(sprintf('xcopy %s %s /Y',originalfilename, tempfilename));
On MS Windows the 'xcopy' command with a /Y option copies the file and overwrites without prompting. Also xcopy is not blocked by the file being open elsewhere whereas a straight 'copy' is blocked. I'm sure there is a similar Linux command.

카테고리

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