C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

conversion of datagrid view to excel format


Posted Date: 09 Aug 2008    Resource Type: Code Snippets    Category: DataGridView
Author: R.SujaaMember Level: Silver    
Rating: 1 out of 5Points: 10



This code is used to convert the datagrid display into excel format. This can be done using the following code.


//export to excel
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);

this.ClearControls(dg);
dg.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());

Response.End();
}



Try this out. I hope this will be helpful



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Excel conversion from datagrid  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Paging and Sorting a GridView in XAML
Previous Resource: Command Name of Hyperlink in DataList C#
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use