Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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(); |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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(); |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exporting data to Excel | Excel Worksheet Functions | |||
Exporting data to Excel | Excel Discussion (Misc queries) | |||
EXPORTING DATA FROM EXCEL TO WORD | Excel Programming | |||
exporting data from access to excel | Excel Discussion (Misc queries) | |||
Exporting Data from Excel | Excel Programming |