Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting data to Excel Peledon Excel Worksheet Functions 6 July 26th 09 05:12 PM
Exporting data to Excel Varne Excel Discussion (Misc queries) 1 September 24th 07 07:55 PM
EXPORTING DATA FROM EXCEL TO WORD Akash Excel Programming 1 February 14th 07 11:08 AM
exporting data from access to excel [email protected] Excel Discussion (Misc queries) 1 April 11th 06 10:17 AM
Exporting Data from Excel Volker Jahn Excel Programming 0 January 13th 04 04:20 PM


All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"