M
manmit.walia
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.NoCache);
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();
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.NoCache);
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();