Exporting data to .xlsm excel file and opening it

hi sir/madam,

I am trying to export huge data to .xlsm file and open it. I am facing problems while opening it.The process is continously running at workbook.save() method without stop.

could you please look into this. it's urgent.

Do note that i am using aspose 7.5.2 version.

please find my application attached.

Hi,


Thanks for sharing the sample project.

I have evaluated your issue and run your project (without any modification with v7.5.2 (latest fix/version)), it works absolutely fine without any issue at all. I could response the file streams fine, I have attached the generated file here for your reference.

Thank you.

hi Amjad,

Thanks for your reply.

Application is working fine, when we are running it locally in our machine, but when we deploy it in IIS server, .XLSM file is not opening.

So, could u please try it in IIS server and then get back to us.

Please reply back soon. Its an Urgent Requirement.

Thank You

Hi,


Aspose.Cells is pure .NET component that does not depend on any environment (desktop or web) or platforms. I think Aspose.Cells does not have any links to your issue, Aspose.Cells uses the Response object on the background for Workbook.Save() method. To confirm your issue on your server, please do not involve Aspose.Cells API, only use File stream to open and re-save the XLSM file, you will see the similar error.

e.g

Sample code:

Workbook workbook = new Workbook(“e:\test2\Book1.xlsm”);

//…
/Send workbook to response/
OoxmlSaveOptions xSaveOptions = new OoxmlSaveOptions(SaveFormat.Xlsm);

MemoryStream tempStream = new MemoryStream();
workbook.Save(tempStream, xSaveOptions);

//set the position.
tempStream.Position = 0;

this.Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;
Response.AddHeader(“content-disposition”, “attachment; filename=output_tempBook_new.xlsm”);
Response.BinaryWrite(tempStream.ToArray());
Response.End();

Thank you.

Hi Amjad ,

Finally at last, we resolved this issue ..

the issue is because of Workbook.save method.

if we replace

workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsm));

with

workbook.Save(filePath,SaveFormat.Xlsm);

ThankYou

Hi,


Good to know that your issue is resolved.

Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you.

Thank you.

hi ,

Can you provide us the correct reason why XLSM file is opened when we used the following save method…

workbook.Save(filePath,SaveFormat.Xlsm);


instead of this-

workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsm));


can u tell me why is the issue with

ContentDisposition.Inline …



Thankyou






Hi,


I am not entirely sure why you find the issue on your end using the line of code:
workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsm));
Could you add a line to the above line if it makes any difference:
Response.End();

Also, you may replace the line with the following:
workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsm));
Response.End();

Thank you.

hi,

We tried using Response.End(),

and tried replacing ContentDisposition.Inline with ContentDisposition.Attachment

but, also the same issue...

Can u get back me on this..

Thank you.

Hi,


As we could not find your issue on our end, we tested your original project and run it on our system but we could not find the issue on our end. I still think Aspose.Cells does not have any links to your issue, Aspose.Cells uses the Response object in the background for Workbook. Save () method. To confirm your issue on your server, please do not involve Aspose.Cells API, only use File stream to open and re-save the XLSM file using the Response object streams, you will see the similar error. I think your issue might be due to your system configuration or browser type on your end only.

Thank you.

hi,

I hope this is not any browser issue ...

Right now , we have no issues at our front -as we solved our problem with

workbook.save(filepath,saveformat.xlsm);

as we replaced with the below method.

but I want to know why the issue with

workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsm));

Thank you

Hi,


As I requested you earlier, please do not involve Aspose.Cells component, please just read / save the XLSM file using FileStream and Response object. I suspect, there is some issue opening the XLSM file on the fly by Response object in your browser type on your end. You should get the similar issue when using your own .NET code replaced by Aspose.Cells code, e.g.workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsm));

Or confirm your issue by replacing the following lines of code in your project with below code instead.
workbook.Save(HttpContext.Current.Response, fileName, ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsm));

with:

/Send workbook to response/
OoxmlSaveOptions xSaveOptions = new OoxmlSaveOptions(SaveFormat.Xlsm);

MemoryStream tempStream = new MemoryStream();
workbook.Save(tempStream, xSaveOptions);

//set the position.
tempStream.Position = 0;

this.Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;
Response.AddHeader(“content-disposition”, “attachment; filename=output_tempBook_new.xlsm”);
Response.BinaryWrite(tempStream.ToArray());
Response.End();

As you can see the bold lines above are not Aspose.Cells APIs, rather these are Asp.NET Response object. You will get the same issue using the above line.

Thanks for your understanding!