1
我想導出顯示在網頁上的圖像。該圖像存儲在Sql圖像數據類型中。顯示圖像時,我將圖像轉換爲Base64String。從SQL Server插入圖像到Word Doc文件
Image1.ImageUrl = "data:image/jpg;base64," & Convert.ToBase64String(imgPhoto)
導出頁面時,圖像不顯示在word文檔文件中。
由於安全原因,我無法將圖像存儲在服務器上。以下代碼的 用於導出爲word文件。
Response.AddHeader("content-disposition", "attachment;filename=Test.doc")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/ms-word "
Response.Charset = ""
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
' Create a form to contain the grid
ControlID.RenderControl(htmlWrite)
Dim stringWrite1 As New System.IO.StringWriter()
Dim htmlWrite1 As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite1)
' Create a form to contain the grid
ImageLogo.RenderControl(htmlWrite1)
Response.Write(stringWrite1.ToString() & stringWrite.ToString())
Response.[End]()