S
simmonsj_98
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. I’m 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();
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. I’m 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();