Thursday, February 3, 2011

export to word

 Export("attachment;filename='" & txtSubject.Text.Trim & "' Report.doc", "application/vnd.doc")
 Sub Export(ByVal header As String, ByVal type As String)
            Try
                Response.Clear()
                Response.Charset = ""
                Response.AddHeader("content-disposition", header)
                Response.ContentType = type
                Response.Cache.SetCacheability(HttpCacheability.NoCache)
                Dim stringWrite As New System.IO.StringWriter()
                Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
                Dim te As New HtmlTable
                Dim tr As New HtmlTableRow
                Dim td As New HtmlTableCell
                td.InnerHtml = SubMailBody()
                tr.Cells.Add(td)
                te.Rows.Add(tr)
                te.RenderControl(htmlWrite)
                Response.Write(stringWrite.ToString())
                Response.End()
            Catch ex As Exception
            End Try
        End Sub

No comments :

Post a Comment