I am iterating through multiple recordsets to create multiple Excel worksheets that can take up to 30 seconds for the results, so I want to provide the user with feedback. A Processing.gif would be fine, but I would rather list the name of each Excel tab as it is being worked on.
Either way, no status shows up, just a blank page while the Excel file is being built.
Here is very sparse default.aspx
<form id="form1" runat="server">
<div>
<!-- never shows -->
<asp:Image AlternateText="Processing for download" ImageUrl="/Images/Wait_Loader.gif"
</div>
</form>
The code uses NPOI to build the spreadsheet file.
//*** New worksheet
Sheet sheet;
sheet = workbook.CreateSheet(sWorksheetName);
// Save the Excel spreadsheet to a MemoryStream and return it to the client
using (var exportData = new MemoryStream())
{
workbook.Write(exportData);
string saveAsFileName = sFileName + ".xls";
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", saveAsFileName));
Response.Clear();
Response.BinaryWrite(exportData.GetBuffer());
Response.End();
}
All of this code works just fine, but when try to set the text of a label control or view a processing.gif, it is still just a blank screen. When I tried a Response.Write, I got statuses followed by the error Server cannot set status after HTTP headers have been sent
It seems like there is a collision between my Response.Writes and the NPOI using the Response object to write to the file.
How do I get something besides a blank window?