How to export image to Excel document

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--------------------------------------
 
S

Steve C. Orr [MVP, MCSD]

You can get the image to show if you use an absolute URL to refer to the
image instead of a relative one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top