423,516 Members | 2,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

How to export image to Excel document

P: n/a
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--------------------------------------

Apr 26 '06 #1
Share this Question
Share on Google+
2 Replies


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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<wu******@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
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--------------------------------------

Apr 26 '06 #2

P: n/a
Ben
Thanks Steve,

Could you please show a sample code or how to implement it?

Ben

Steve C. Orr [MVP, MCSD] wrote:
You can get the image to show if you use an absolute URL to refer to the
image instead of a relative one.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<wu******@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
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--------------------------------------


Apr 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.