We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel xlsm file locked by self upon opening from web

Hi,

I'm fetching an Excel workbook from our intranet site and upon attemting any edits, it gives me that "File is in use" dialog with the xxxxx.xlsm is locked for editing by [my username]

The code creates a designer.workbook object opened using a blank .xlsm file, with some vba code in it. It adds some data via smart-markers. Then the call in the web code is:

designer.Workbook.Save(Response,somefilename.xlsm,ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Xlsm)); (using aspose.cells 7.4.3.1)

This exact code worked fine when the workbook was a ver. 2003 .xls file, and the code used the SaveFormat.Excel97to2003. There were no locking issues.

Also of note--the file contains a link to itself (not my doing--not sure why it contains this link)--when I click the "enable macros" button, there is also the "update links" option, which I normally don't see. Inspecting the link shows the exact same filename. If I save the file first to my drive, then reopen, I don't have the problem. However, from a useability standpoint, the users will typically want to open the sheet, look at it, maybe do some things with it, then discard it without saving. So it's an extra hassle to have to tell the users to save it first and I'd like to avoid that if possible.

Have I taken a wrong turn in this? I have tried forcing the Workbook object to FileFormatType.Xlsm instead of leaving the default, but no joy.

Thanks for any help on this.

Hi,


Well, as you said, if you save the file to disk, then open it, it works fine. So, we think the issue might not be related to Aspose.Cells by any means. For confirmation, you may try to use FileStream .NET APIs and without using Aspose.Cells APIs to open and save the file, you should get the similar problem.
If you find it works fine, then please create a sample project (runnable) with Aspose.Cells APIs, zip it and post it here with all the files, we will check it soon.


Also, your line of code to save to XLSM file format should be:
workbook.Save(Response,somefilename.xlsm,ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsm));
Response.End();

Thank you.