PC Review


Reply
Thread Tools Rate Thread

C#.Net Excel exporting web form instead of data

 
 
Liz
Guest
Posts: n/a
 
      5th Jan 2005
Hi! I have a .Net webpage that displays data in some datagrids populated
based on user search criteria. There is a button, that when clicked, the
data is exported to excel. For one user, I am seeing that it works
correctly the first time he tries the report, but if he reruns the
result set or even picks a different report, the web page itself is
exported to excel and not the data. He has the same Excel version as
others (Excel 2003) who are not able to recreate the issue. No errors
are sent to the client.

Has anyone ever seen this? Here's the code:

private void btnExport_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

oHtmlTextWriter.Write("Overall Total Number of Searches: "
+lblTotSearches.Text);
oHtmlTextWriter.Write("<br>");

dgOrg.RenderControl(oHtmlTextWriter);
oHtmlTextWriter.Write("<br>");
dgFuncArea.RenderControl(oHtmlTextWriter);
oHtmlTextWriter.Write("<br>");
dgBodyArea.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());
Response.End();
}

Thanks!!
Liz

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Winform Exporting Data to Excel form Datagridview Nischal Microsoft Excel Programming 0 28th Nov 2007 07:16 PM
Exporting Word Form Data into Excel =?Utf-8?B?RGF6ZWQmQ29uZnVzZWQ=?= Microsoft Word Document Management 2 24th Mar 2006 07:57 AM
Exporting one value from a Access data entry Form to Excel morry Microsoft Access External Data 1 25th Jun 2005 08:20 AM
RE: Exporting form data to excel =?Utf-8?B?UGF0IGhhcnRtYW4=?= Microsoft Access External Data 0 29th Jul 2004 02:45 AM
Exporting data to Microsoft Excel from a Web Form (using OWC) problem sarah5e@yahoo.com Microsoft ASP .NET 1 10th May 2004 02:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 AM.