From: Julie Ward on
http://www.mathworks.ch/matlabcentral/newsreader/create_message

I have a Matlab program that makes several sequential xlswrite statements to an Excel 2007 spreadsheet (*.xlsx file) .

Even though the spreadsheet is closed and no other process is (or, appears to be) using it, I get an error message after xlswrite statements (not the first).

??? Error using ==> xlswrite at 253
The file C:\....\myfile.xlsx is not writable. It
may be locked by another process.


Based on other suggestions on this forum for different but related problems, I have tried modifying the xlswrite statements as follows:

status = xlswrite('myfile.xlsx', thing1,'Sheet1','B3:B22');

while (status==0)
pause(0.1);
end;

status=xlswrite('myfile.xlsx', thing2,'Sheet1','C3:G22');

I tried this approach but it was glacial and I eventually had to kill the process. For some reason my "status" seems to be stuck zero for a long time after certain calls for xlswrite.

I would love any suggestions! Thanks so much.
From: Bob Gilmore on
"Julie Ward" <julie.drew(a)gmail.com> wrote in message
news:hpnp16$luc$1(a)fred.mathworks.com...
> http://www.mathworks.ch/matlabcentral/newsreader/create_message
>
> I have a Matlab program that makes several sequential xlswrite statements
> to an Excel 2007 spreadsheet (*.xlsx file) .
> Even though the spreadsheet is closed and no other process is (or, appears
> to be) using it, I get an error message after xlswrite statements (not the
> first).
>
> ??? Error using ==> xlswrite at 253
> The file C:\....\myfile.xlsx is not writable. It
> may be locked by another process.
>
>
> Based on other suggestions on this forum for different but related
> problems, I have tried modifying the xlswrite statements as follows:
>
> status = xlswrite('myfile.xlsx', thing1,'Sheet1','B3:B22');
>
> while (status==0) pause(0.1); end;
> status=xlswrite('myfile.xlsx', thing2,'Sheet1','C3:G22');
>
> I tried this approach but it was glacial and I eventually had to kill the
> process. For some reason my "status" seems to be stuck zero for a long
> time after certain calls for xlswrite.
>
> I would love any suggestions! Thanks so much.

Julie,
This won't help with your overall problem, but I still have to ask...

I don't understand what you're doing with that WHILE loop.

You ask for "status," then check "status" as the condition of a while loop,
and never do anything in that while loop to either break out OR to update
"status."

So it seems to me that if, on a particular save, "status" is non-zero, and
you enter that loop, that's it. Youre GOING to "hang" and have to
interrupt.

You should probably rethink that approach.
--
Bob Gilmore, The MathWorks, Inc.


From: Julie Ward on
Hi Bob,
I was hoping status would update itself to 1 when the xlswrite command completed. Perhaps that was optimistic :)
Julie
 | 
Pages: 1
Prev: jpeg2000
Next: Switch statements