This is to get the gridview values of your page in to microsoft excel. Recently i tried this. we can export values from gridview or DataList or any DataRenderControl. For this code is as follows..
first in aspx page put a gridview and a button to export to excel and in page load bind data to gridview.
in button click write this code.
Sub btnExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnExcel.Click
Response.ContentType = “application/vnd.ms-excel”
Dim objStringWriter As New IO.StringWriter
Dim objHtmlTextWriter As New Html32TextWriter(objStringWriter)gdvDetails.RenderControlobjHtmlTextWriter)
Response.AppendHeader( “Content-Disposition”, “attachment; filename=Details.xls”)
Response.Write(objStringWriter)
Response.Flush()
Response.End()
End Sub
when you click on this button it gives a popup like “download file menu” with the name “Details.xls”. you can open or save into your system