How to export image to Excel document

  • Thread starter Thread starter wubin_98
  • Start date Start date
W

wubin_98

Hi,
I want to export a gridview data and a image from image control to
export to an Excel document.

When I executed following code, GridView data was exported to Excel
properly. But no image was displayed in Excel. Only a blank image icon
was show inside Excel.


Could any body point out what is wrong in my code or missing anything?

Thanks,

--------------Begin of Code--------------------------------------
Response.Clear()
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=" & "ImageChart.xls")

EnableViewState = False
Controls.Add(frm)
frm.Controls.Add(GridView1)
frm.Controls.Add(Image1)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
--------------End of Code--------------------------------------
 
You can get the image to show if you use an absolute URL to refer to the
image instead of a relative one.
 
Back
Top