DotNet Gallery



Login
Register
Contact Us
Privacy

Home Discussion Forum Questions and Answers Discussion Forum Gridview export to excel
Gridview export to excel
Category : Asp.Net by Parasu
Posted on 29/08/2008
Discussion Forum

hi guys

I want code for export data from Gridview.

Thanks
Paras

Answers
shine joseph on 07/10/2008
It is quiet simple use the following code

' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel"

'Turn off the view state
Me.EnableViewState = False

'Remove the charset from the Content-Type header
Response.Charset = String.Empty

Dim myTextWriter As New System.IO.StringWriter()
Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter)

'Get the HTML for the control
myDataGrid.RenderControl(myHtmlTextWriter)

'Write the HTML to the browser
Response.Write(myTextWriter.ToString())

'End the response
Response.End()


also if you want Please refer the follwing link

http://www.dotnetjohn.com/articles.aspx?articleid=78
or
http://codebetter.com/blogs/darrell.norton/archive/2004/02/12/7154.aspx
or
http://support.microsoft.com/kb/317719 or

the second one is a simple one that can be understand very easily

Thanks
Post Answer
Please sign in to Post Answer


Copyright©2008 Dot Net Gallery. All Rights Reserved.| Privacy Policiy | Contact