473,385 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Exporting Image and GridView to Word/Excel is Impossible!

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();

Jul 11 '06 #1
2 3618
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();

Jul 13 '06 #2
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();
Jul 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pranav | last post by:
I've a web page that displays report data in a data grid an a chart ( I'm using Chart Fx for .Net which creates .PNG files on Server) I've a requirement to export the datagrid and chart both to...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
2
by: Yaseen D M | last post by:
I have aspx page which contains some gif, jpg and png images. PNG image is generated dynamically. This file is basically a graph image. The problem i am facing in exporting these images to word,...
2
by: wubin_98 | last post by:
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...
4
by: Tom | last post by:
I have a gridview on all of my web pages in my web app and they all export to excel. I have one page where the gridview is binding to a datatable that i created and only the first column is...
3
by: aSoundMind | last post by:
Hello Guys, I am not sure is this a common problem. I can't display image which in a gridview to excel or word. I have not try on pdf or web but surely this annoy me. I tried to google it and...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each...
1
by: Yordan Georgiev | last post by:
I have a search form using master page , which is dynamically generated from the column names of the database - when the users have a search result it should be exported to Excel by clicking the...
2
by: ASF | last post by:
Hey all, I have a gridview with an objectdatasource. I've been using the below code to export to excel: gvITV.AllowSorting = False gvITV.DataBind() Dim tw As New IO.StringWriter() Dim hw As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.