Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Page_Load(object sender, EventArgs e)
- {
- handleExport();
- }
- void handleExport()
- {
- // ...
- // Code to produce spreadsheet is here...
- // ...
- // Write the Excel spreadsheet from the MemoryStream and send it to the browser
- string saveAsFileName = sFileName + ".xlsx";
- Response.Clear();
- Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", saveAsFileName));
- workbook.Write(Response.OutputStream);
- Response.Flush();
- Response.Close();
- Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
- }
Add Comment
Please, Sign In to add comment