Exporting datagrid from to an Excel, Word and notepad format


Many times we would like to export our page as an Excel sheet, Word doc or PDF file. This can be simply achieved by changing the ContentType of the Response object and overriding the RenderControl method of the control to be exported

Export to Excel,word and notepad are one of the most common functionality required in ASP.Net pages.Users can download the data from the datagrid into an Excel spreadsheet for offline verification and/or computation. This article includes the source code  for such functionality.

How it works

This main functionality to Export a datagrid from an ASP.Net Web Form to an Excel,word and notepad format is actually very simple. There are several solutions for this implementation and in this example we will convert the datagrid to excel,word and notepad format. The RenderControl method available in the .Net Framework provides the server control content to an HtmlTextWriter which is subsequently written out to the Response Stream.


Similar Articles