Read and write data to an open excel file.
61 ビュー (過去 30 日間)
古いコメントを表示
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 !
0 件のコメント
回答 (2 件)
Emmanuel J Rodriguez
2022 年 4 月 13 日
Hello, take a look at this answer: https://www.mathworks.com/matlabcentral/answers/577870-write-to-an-already-opened-excel-file#answer_478051
8 件のコメント
Emmanuel J Rodriguez
2022 年 4 月 26 日
Also, make sure all MS Excel instances are closed before executing the code.
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!