473,609 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

export gridview images to excel

3 New Member
Hi,

I'm trying to convert a gridview to an excel report and have one small hang up. So far I've been able to create my gridview and export it to excel ok, but in my gridview I have an image. The problem is, the image won't display unless I'm connected to the Internet or if I use a relative path and have the image stored relative to the excel file. Is it possible to "embed" the image from the gridview into the excel workbook so I could give the excel workbook to anyone without needing connection to the Internet or having the images locally. I'd like it all to be one excel file.

This is the code I'm using to create the excel workbook.

Expand|Select|Wrap|Line Numbers
  1.         Response.Clear();
  2.         Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
  3.         Response.Charset = "";
  4.         Response.Cache.SetCacheability(HttpCacheability.NoCache);
  5.         Response.ContentType = "application/excel";
  6.         System.IO.StringWriter stringWrite = new System.IO.StringWriter();
  7.         System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
  8.         this.GridView1.RenderControl(htmlWrite);
  9.         Response.Write(stringWrite.ToString());
  10.         Response.End();
I'm open to any other suggestions that might work to get basically an image and some data into an excel workbook from a mysql database. I'm using ASP.NET C#

Thanks
Jul 31 '07 #1
1 3360
jhardman
3,406 Recognized Expert Specialist
moved to .NET forum. hopefully you will get better responses here.

Jared
Aug 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
671
by: Paul Zanbaka | last post by:
I have this code below it works fine when exporting to excel. However 2 things: 1-It does prompt me to save to file to excel (just displays excel in browser) 2-It aonly works if AllowSorting="false' in <asp:GridView > tag Can anyone help! -- Paul
2
9219
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?
0
1233
by: Peter | last post by:
I experienced a bug, "Control GridView1 of type GridView myst be placed inside a form tag with runat=server". But I did so. I do not why, please advise. my code as below. Thanks. Peter <%@ Page language="C#" %> <script runat="server"> protected void Page_Load(object sender, EventArgs e) {
5
2812
by: karthick | last post by:
Hi, I am exporting a Gridview to Excel and it works fine without any issues. But as one of the field holds values such as "71646E100" it gets converted to: "7.16E+104" (like a formula) in Excel. How can I prevent this from happening ?. I need to value to be in Excel as it is displayed in the Gridview (on the web page).
3
10105
by: =?Utf-8?B?bWFuaWthMDI=?= | last post by:
Hi, I have a GridView control in page called eventslisting which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type GridView must be placed inside form tag with runat = server". I understand that this is because my Masterpage has the formtag and not the eventslisting page. As a workaround I programatically created an HTML form, added runat=server attribute to it...
0
1691
by: johnlim20088 | last post by:
Hi, Hi, currently I have a code below on my Listcontact.aspx file to export my gridview data to excel:- It is work success, and export the 'Contacts.xls' to my folder. But have following problem-> 1) when i open with wordpad, it show html tag with the value. 2) when i open with excel, it look ok, BUT i don't want the colour and button to be export.
6
6472
by: Sergio E. | last post by:
Hi, I'm looking for information about gridview's cell properties... I've the following case: one gridview with alternatirg row style and normalrowstyle, 3 o 4 custom styles that are applied to cells in the row_databound event, and now I nedd to do a excel export of the gridview exactly as is showed in the browser, but al the examples and thigs I've tried don't send the cell color to excel and now I think if I can read the gridview...
0
1549
by: =?Utf-8?B?U2hhbQ==?= | last post by:
Hai all, In my application, I need to Export webpage things into hard drive. I am using gridview, and i export all things(with the help of some sites) into excel except images. Please, Can any one tell me how to export all contents of(Including Images) gridview into excel.
0
1911
by: hiranmaie | last post by:
Hi, I have a gridview with more than 10 rows of data. I want to export these gridview values into an excel sheet along with the header names of excel sheet. I am not using a database here. I need to open an excel application at the click of a button and save the gridview values into the excel sheet opened. Please help me out to solve this problem. Thanks & Regards,
0
8109
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8035
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
8534
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...
0
8509
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8188
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,...
1
6034
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
5502
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
4059
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2502
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

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.