I use xlswrite and xlswritespec all the time. I am having a specific problem with xlswrite (see below)

2 次查看(过去 30 天)
What I want to do is use 1 script to write to an Excel File on one sheet. After this is complete I want a second script to write additional data to a different sheet on the same file. I am getting errors when I try to perform the second write because xlswrite returns a message that says the file is now write locked. How can I get past this problem?

采纳的回答

Naman Chaturvedi
Naman Chaturvedi 2018-9-20
Did you make sure that the file is not open?
xlswrite() actually launches Excel and tries to open the file. So if you have the file already opened in Excel, even though you launched it via ActiveX, you won't be able to write to it because the ActiveX process has ahold of it.

更多回答(1 个)

Stephen Forczyk
Stephen Forczyk 2018-9-20
I agree that I think the problem is one of file permissions. Recall that I used two separate scripts (one was a data preprocessor the next a postprocessor). The first script was complete and wrote the file. The plan was for the second script to re open it and then continue writing to the same file on a different tab. I did not have the Excel file open. I think that somehow Active X COM server still had the file in its grip!

类别

Help CenterFile Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by