Macro issue downloading XLSM file with no save to disk

Sample code is attached.

The issue occurs when I'm downloading an XLSM file without saving it to hard disk first. Run the attached application and press the open button (not the save button). When you try to run the macros on Sheet1, you will get an error message that says the file is locked for editing.

If you save the workbook to disk first, then open into excel 2007 (or 2010), the macros work just fine.

Thanks very much! Cindy

Sorry, forgot to say that I’m currently on version 5.1.2.8.

Dear Cindy,

Thanks for your sample project and the files. We will look into this issue and resolve it as soon as possible.

Meanwhile, you can check your application with the latest version Aspose.Cells for .NET 5.2.1.2. Find its link from this thread.

<a href="

I get the same issue with the latest version 5.2.1.2 - thank you for looking into this for me.

Cindy

Hi Cindy,

Seems like your Book2.xlsm is password protected. Will you attach it without password or tell me what is its password; so that I could look into it.

Sorry about that - was testing a few things out and forgot to unprotect…it is attached.

Hi,

Your mentioned issue is not related to Aspose.Cells by any means. For confirmation, when you try to open/save an existing file using .NET File Streams without using Aspose.Cells for .NET API, you can find the same issue. e.g

FileStream fs = File.OpenRead(strFilePath);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
Response.Clear();
Response.ClearHeaders();
Response.ContentType = “application/vnd.ms-excel”;
Response.AddHeader(“Content-Length”, data.Length.ToString());
Response.AddHeader(“content-disposition”, “attachment; filename=Book1.xls”);
Response.BinaryWrite(data);
Response.End();

Thank you.

Thank you very much for you assistance…

Cindy

I understand this is is non an Aspose issue, but is there anyway to get this to work, i.e. dynamically create an xlsx/xlsm document and return it to the client browser without the locked issue?


Thanks!
/Fredrik

Hi Fredrik,

I am not sure if there would be any option/alternative to it. As, you can see that simple streaming the file to response to the user without involving Aspose.Cells API will still produce the issue.

Anyways, if we find anything, we will let you know surely.

Thank you and have a good time.