Hi Everyone,
I do also have the same problem....
I have also given the full path of image,but still it is not showing
the image in Word document...
The GridView writes to the word document
but not the image. All it show is a red 'x' image . but on clicking
the image on word document it display the image....
any help would be gratefull..
thanks
Pankaj
Steve C. Orr [MVP, MCSD] wrote:
You need to make sure you're specifying the full path to the image, not a
relative path.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<ma**********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hello Fellow Developers,
I have a small problem that you might be able to help me with. The
method that I am trying to create is the ability to export a GridView
and a image to word or excel. I know that some people have already post
about this topic but could not find a reliable answer. To my knowledge,
I have the code down right. The GridView writes to the word document
perfectly just not the image. All I get is a red 'x' image notifying me
that word cannot find the path of the image.
Below is my code. Any help would be grateful.
Legend:
---------------------------------
partsGrid = GridView
pieImage = asp.net Image, which is dynamically created using GDI+
---------------------------------
intro = "<div align=center><font style=FONT-SIZE:'18pt'; COLOR:
'#8B0000'; FONT-FAMILY: 'Verdana'>" + rptlbltype.Text +
"</font></div><br>";
intro = intro + "<div align=center><font style=FONT-SIZE:'11pt'; COLOR:
'#8B0000'; FONT-FAMILY: 'Verdana'>Date From" + " " + sDate.Text + " " +
"to" + " " + eDate.Text + "</font></div><br>";
string temp = rptlbltype.Text + "-" + " " + sDate.Text + "to" +
eDate.Text;
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" +
rptlbltype.Text + ".doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
StringWriter stringWrite2 = new StringWriter();
HtmlTextWriter htmlWrite2 = new HtmlTextWriter(stringWrite2);
partsGrid.RenderControl(htmlWrite);
pieImage.RenderControl(htmlWrite2);
string totalText = intro + stringWrite.ToString() + "<br/>" +
stringWrite2.ToString() ;
Response.Write(totalText);
Response.End();