Hi,
We are using Aspose.Excel in c# .Net 2.0 to download data in Excel spreadsheet
On downloawd there’s a blank browser window with “Opem/Save/Cancel” popup.
The browser window remains open after “Open” or “Save” the Excel file.
Is there a way to close or eliminate a blank browser window?
Download workflow on Page_load mainly has 3 steps:
- Create spreadsheet;
- Fill it with data
- Save spreadsheet as HTML
Below is the code sample:
//1. Create spreadsheet
Aspose.Excel.License lic = new Aspose.Excel.License();
lic.SetLicense("../Aspose.Custom.lic");
Excel excel = new Excel();
Cells dtcells = excel.Worksheets[0].Cells;
//2. Populate spreadsheet with data
.....
//3. Save spreadsheet as HTML
MemoryStream mstr = new MemoryStream();
excel.Save(mstr,FileFormatType.Excel97);
Response.ClearHeaders();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-disposition",string.Format(@"attachment; filename={0}.xls", "MyDownload"));
Response.BinaryWrite(mstr.GetBuffer());
mstr.Close();
Response.End();
Thanks.
Hi,
Well, I think that's the routine and behavior of the browser when sending/retrieving files through Response object, there is nothing to do with Aspose.Cells for .NET.
Thank you.
Amjad, thanks for your reply.
We are creating an Excel file dynamically on web server and sending it to the client.
I tried to play with the following code:
MemoryStream stream = new MemoryStream();
excel.Save(stream, FileFormatType.Default);
byte[] data = stream.ToArray();
Response.ContentType = "application/xls";
// "Open file In Excel" option:
Response.AddHeader("content-disposition", "attachment; filename=download.xls");
Response.BinaryWrite(data);
Response.End();
We need a browser window to be closed after user make selection in modal popup from Open\Save\Cancel".
It happens in IE7 or if file opens in browser at [Response.AddHeader("content-disposition", "inline; filename=download.xls"); ]. But in IE6 it stays opened.
May be you have an idea what caused this and how we could control it.
Thanks,
Vladimir..
Strange behavior we have only in IE6: when user selects "Open" from prompt then file is opened in Excel and "blank" browser window is closed in IE7 but stays opened in IE6.
May be you have an idea why it is happened?
Thanks,
Vladimir.
Hi Vladimir,
Well, I think this is the behavior of IE6.0 that does not close the browse window when you utilize the download dialog box. But we checked in IE7.0 it does close the window. I think to close the window in ie6.0, you may try to control it by yourself.
Thank you.