KB39 - Why do I get a "locked for editing" error and I can only open the spreadsheet as Read Only?

Description

You may get a workbook.xls is locked for editing by 'another user' Error when trying to open the spreadsheet that was streamed to the browser.

Solution

This problem is caused by an IE bug or quirk that causes it to request the spreadsheet twice from the server. Because each opened workbook in Excel must have a unique name, Excel will not allow you to open it when the spreadsheet is generated for the second time. Instead it lets you open the original spreadsheet as Read Only.
 
This can even crash Excel or cause Excel to call the file corrupt even though if you chose to Save it to disk instead of Opening it, the file would actually not be corrupt.
 
 
Workarounds:
You can use the SaveLocally method to save the spreadsheets to the Server and then have the browser open a URL that points to the saved file. (or you could have a script that redirects the user to the appropriate saved file)
You can choose to Save the file instead of opening it when the browser prompts you. Or you can right-click the link and choose Save Target As..
 

Copyright © 1999-2006 Optimized Software. All Rights Reserved.
Microsoft® Excel is a registered trademark of Microsoft Corporation.