Code: Select all
//*****************************************
//* Workbook Download & Cleanup
//*****************************************
using (var stream = new MemoryStream())
{
Response.Clear();
wb.Write(stream);
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "Student Experiences.xlsx"));
Response.BinaryWrite(stream.ToArray());
Response.Flush();
Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}