![]() |
Exporting data to Excel
I have a pop-up web page that takes a dataset and exports it to Excel. I
have included the code sample below. When I run this on my local environment I get a file download dialog that recognizes that format is excel and will open the file. However when I deploy it to our staging environment the pop-up window opens and then immediately closes. Im guessing that I need to change a setting on the staging server, but have no idea what that may be. Could anyone provide any insight to this problem? Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=WebReport.xls"); Response.Charset = ""; // Set the content type to Excel. Response.ContentType = "application/vnd.ms-excel"; DataSet dsExport = (DataSet)Session["Reportdata"]; System.IO.StringWriter tw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dsExport; dgGrid.DataBind(); // Get the HTML for the control. dgGrid.RenderControl(hw); // Write the HTML back to the browser. Response.Write(tw.ToString()); // End the response. Response.End(); |
Exporting data to Excel
Try adding a wait. had a problem where the program was running so fast it
didn't recognize the prevvious mouse action was released. The code just blew past the response in a pop up window. Application.Wait (Now + TimeValue("0:00:1")) "simmonsj_98" wrote: I have a pop-up web page that takes a dataset and exports it to Excel. I have included the code sample below. When I run this on my local environment I get a file download dialog that recognizes that format is excel and will open the file. However when I deploy it to our staging environment the pop-up window opens and then immediately closes. Im guessing that I need to change a setting on the staging server, but have no idea what that may be. Could anyone provide any insight to this problem? Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=WebReport.xls"); Response.Charset = ""; // Set the content type to Excel. Response.ContentType = "application/vnd.ms-excel"; DataSet dsExport = (DataSet)Session["Reportdata"]; System.IO.StringWriter tw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dsExport; dgGrid.DataBind(); // Get the HTML for the control. dgGrid.RenderControl(hw); // Write the HTML back to the browser. Response.Write(tw.ToString()); // End the response. Response.End(); |
All times are GMT +1. The time now is 02:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com