473,805 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><f ont style=FONT-SIZE:'18pt'; COLOR:
'#8B0000'; FONT-FAMILY: 'Verdana'>" + rptlbltype.Text +
"</font></div><br>";
intro = intro + "<div align=center><f ont 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.AddHea der("content-disposition", "attachment;fil ename=" +
rptlbltype.Text + ".doc");

Response.Charse t = "";

Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

Response.Conten tType = "applicatio n/vnd.word";

System.IO.Strin gWriter stringWrite = new System.IO.Strin gWriter();

System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);

StringWriter stringWrite2 = new StringWriter();

HtmlTextWriter htmlWrite2 = new HtmlTextWriter( stringWrite2);

partsGrid.Rende rControl(htmlWr ite);

pieImage.Render Control(htmlWri te2);

string totalText = intro + stringWrite.ToS tring() + "<br/>" +
stringWrite2.To String() ;

Response.Write( totalText);

Response.End();

Jul 11 '06 #1
2 3650
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**********@g mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.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><f ont style=FONT-SIZE:'18pt'; COLOR:
'#8B0000'; FONT-FAMILY: 'Verdana'>" + rptlbltype.Text +
"</font></div><br>";
intro = intro + "<div align=center><f ont 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.AddHea der("content-disposition", "attachment;fil ename=" +
rptlbltype.Text + ".doc");

Response.Charse t = "";

Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

Response.Conten tType = "applicatio n/vnd.word";

System.IO.Strin gWriter stringWrite = new System.IO.Strin gWriter();

System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);

StringWriter stringWrite2 = new StringWriter();

HtmlTextWriter htmlWrite2 = new HtmlTextWriter( stringWrite2);

partsGrid.Rende rControl(htmlWr ite);

pieImage.Render Control(htmlWri te2);

string totalText = intro + stringWrite.ToS tring() + "<br/>" +
stringWrite2.To String() ;

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**********@g mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.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><f ont style=FONT-SIZE:'18pt'; COLOR:
'#8B0000'; FONT-FAMILY: 'Verdana'>" + rptlbltype.Text +
"</font></div><br>";
intro = intro + "<div align=center><f ont 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.AddHea der("content-disposition", "attachment;fil ename=" +
rptlbltype.Text + ".doc");

Response.Charse t = "";

Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

Response.Conten tType = "applicatio n/vnd.word";

System.IO.Strin gWriter stringWrite = new System.IO.Strin gWriter();

System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);

StringWriter stringWrite2 = new StringWriter();

HtmlTextWriter htmlWrite2 = new HtmlTextWriter( stringWrite2);

partsGrid.Rende rControl(htmlWr ite);

pieImage.Render Control(htmlWri te2);

string totalText = intro + stringWrite.ToS tring() + "<br/>" +
stringWrite2.To String() ;

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
1833
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 Excel/Word When I stream the above ASPX page with Content Type set to Excel or Wor I get the Grid data exported Just fine, but I get empty image, where th chart should be. I've tested to see the imagefiles are still accessible through their URL
1
3173
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 As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
2
2266
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, excel and pdf. Is there anyway to export these images in ASP.NET I need solution urgent. Regards,
2
9241
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 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?
4
2523
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 exporting to excel. How can I get the entire grid to export to excel?
3
1466
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 the best I can found is this code which mentioned something tat it is due to excel limitation and so we need to use absolute path.
0
1800
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 column and displaying the total in the footer of the gridview. Now I export the gridview to excel spreadsheet with the code below. Everything is exported well except the footer value become zero in the excel spreadsheet. Can anyone tell me how can i...
1
3403
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 button ... I get the following message : A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in...
2
4231
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 New System.Web.UI.HtmlTextWriter(tw) Dim frm As HtmlForm = New HtmlForm() Response.ContentType = "application/vnd.ms-excel"
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.