Posted on: 11/15/2013 7:27:27 AM | Views : 607

 hi i am using this code for exporting gridview data to excel but ms word is opening please help...
Protected Sub LinkButton7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton7.Click ExportToExcel("Report.xls", GridView1) GridView1 = Nothing GridView1.Dispose()
End Sub Private Sub ExportToExcel(ByVal strFileName As String, ByVal gv As GridView) Response.ClearContent() Response.AddHeader("content-disposition", "attachment; filename=" & strFileName) Response.ContentType = "application/excel" Dim sw As New System.IO.StringWriter() Dim htw As New HtmlTextWriter(sw) gv.RenderControl(htw) Response.Write(sw.ToString()) Response.[End]()
End Sub

Go to the complete details ...