Hi, I have an export to excel functionality in my site, which I’m implementing using Aspose.Cells.
I’ve recently found an issue that’s causing the IIS to hang following these steps:
- Click to export an excel file
- In the download prompt, choose “Open”, not “Save”
- File gets open and everything looks good
- Go back to site and export another excel file (WITHOUT CLOSING THE PREVIOUSLY EXPORTED ONE)
- Choose “Open” again in the download prompt
- File doesn’t open, and IIS hangs. The website is unresponsive.
This is the code I’m using to export to excel files:
Dim workbook As New Aspose.Cells.Workbook()
Dim worksheet As Aspose.Cells.Worksheet = workbook.Worksheets(0)
worksheet.Cells.ImportCustomObjects(CType(items.ToArray, System.Collections.ICollection), {“Column 1”, “Column 2”, “Column 3”, “Column 4”, “Column 5”}, True, 0, 0, items.Count, True, “mm/dd/yy”, False)
workbook.Save(Me.Response, “report.xls”, ContentDisposition.Inline, New XlsSaveOptions(SaveFormat.Excel97To2003))
I’d really appreciate any pointer on how to solve this issue.
Thanks!
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
Please download and use the latest version:
Aspose.Cells for .NET (Latest Version)
It should solve this problem.
Please also note down, that you will have to use .net2.0 folder dll if your net framework is not client profile. If your net framework is client profile then use the dll in client profile folder.
If the problem still occurs, then please provide us the screenshot for more illustration of this issue.
We will look into it and help you asap.
Thanks for your reply. I was about to update the issue with the solution in case anyone find it useful.
The problem was not IIS hanging actually, it was Internet Explorer.
The problem had to do with the Content Disposition = Inline
I changed it to Content Disposition = Attachment and everything is working perfect.
Thanks again for your help.
Hi,
It’s good to know that you were able to resolve this issue.
Thanks for sharing your feedback and information.
You are right, the issue was due to not using ContentDisposition.Attachment.
Here is a complete runnable test code that you can use to test your file.
C#
//Create a new Workbook.
Workbook workbook = new Workbook();
string outputFormat=“XLS”;
if (outputFormat == “XLS”)
{
//Save file and send to client browser using selected format
workbook.Save(HttpContext.Current.Response, "Output.xls", ContentDisposition.Attachment, <span class="kwrd">new</span> XlsSaveOptions(SaveFormat.Excel97To2003));
}
else
{
workbook.Save(HttpContext.Current.Response, “Output.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
}