C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to Export the gridview results in an excel sheet.


Posted Date: 20 May 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: Sukanya Member Level: Diamond    
Rating: Points: 10



The following code will help you how to export gridview results in an Excel sheet.

Try


Response.HttpContext.Current.Response.Clear()
Response.HttpContext.Current.Response.Charset = ""
'set the response mime type for excel
Response.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"

Response.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=ExcelFileName.XLS")
Dim stringWrite As new System.IO.StringWriter()

Dim htmlWrite As new HtmlTextWriter(stringWrite)

myDataGrid.RenderControl(htmlWrite)

Response.Write(stringWrite.ToString())



Catch ex As Exception
Response.Write("Error: " & ex.Message)
End Try





Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Export the gridview results  .  

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: How to fix max char width of gridview column
Previous Resource: How to show images in GridView
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use