將FormView,GridView匯出到word

 

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
   Dim name As String = "attachment;filename="
   name += Request.QueryString("name") + ".doc"
   Response.Clear()
   Response.AddHeader("content-disposition", name)
   Response.Charset = "UTF-8"
   Response.ContentType = "application/vnd.ms-word"
   Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
   Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
   FormView1.RenderControl(htmlWrite) '<--非GridView1請更改為要輸出名稱
   Response.Write(stringWrite.ToString)
   Response.End()
End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 毛魚 的頭像
    毛魚

    機車,攝影,網頁程式分享

    毛魚 發表在 痞客邦 留言(0) 人氣()