473,657 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export Datagrids to Excel

Hi, I am using the code below to export a webpage to Excel. The webpage has
three datagrids on it and they are all exported to Excel properly and
everything looks very nice, but we would really only like two of the three
datagrids to be exported. Is there a way to exclude certain sections of the
webpage from being exported to Excel? "DG" in the code here is one of the
datagrids on the page:

----------------------------------------------------
Dim resp As HttpResponse
resp = Page.Response
resp.ContentTyp e = "applicatio n/download"
Page.EnableView State = False
resp.Charset = String.Empty
resp.AppendHead er("Content-Disposition",
"attachment;fil ename=Container Report.xls")
Dim colHeaders As String

Dim tw As New System.IO.Strin gWriter
Dim hw As New System.Web.UI.H tmlTextWriter(t w)

DG.RenderContro l(hw)
----------------------------------------------------
Thanks!
John
Nov 21 '07 #1
1 1312
Check out this article (it shows you how to configure the export just for one
grid):

http://www.dotnetjohn.com/articles.aspx?articleid=231

More info about Excel generation on ASP .net:

http://www.tipsdotnet.com/ArticleBlo...a=&PageIndex=0

--
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"John Walker" wrote:
Hi, I am using the code below to export a webpage to Excel. The webpage has
three datagrids on it and they are all exported to Excel properly and
everything looks very nice, but we would really only like two of the three
datagrids to be exported. Is there a way to exclude certain sections of the
webpage from being exported to Excel? "DG" in the code here is one of the
datagrids on the page:

----------------------------------------------------
Dim resp As HttpResponse
resp = Page.Response
resp.ContentTyp e = "applicatio n/download"
Page.EnableView State = False
resp.Charset = String.Empty
resp.AppendHead er("Content-Disposition",
"attachment;fil ename=Container Report.xls")
Dim colHeaders As String

Dim tw As New System.IO.Strin gWriter
Dim hw As New System.Web.UI.H tmlTextWriter(t w)

DG.RenderContro l(hw)
----------------------------------------------------
Thanks!
John
Nov 21 '07 #2

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

Similar topics

2
1657
by: Benny | last post by:
Hello Experts, I am currently working on a web application using vs.net 2002 with c#. Assume I have a page with 3 datagrids, how can I export these 3 datagrids to an excel file with 3 sheets, where each sheet contain 1 datagrid data? Thanks,
0
1277
by: Steve Chatham | last post by:
I need to export multiple datagrids (where we have a drill-through web application) into an Excel workbook. For instance, when you click on the first datagrid, you get a subset of the sql table. Subsequent clicks on those items in the table further filter the request, until you go from a business area down to a single SKU. Thus far, I have gotten it to work, but there have been size issues (I guess, as smaller files seem to do okay),...
9
3002
by: | last post by:
I have a web page written in asp.net that has multiple datagrids on it that would need to be exported to Excel. Each of the datagrids would be a subset of what the datagrid above it was. Thus far, I've had no luck in finding anything to work reliably. Some of the files I've saved (using a radio button click event), will open fine in Excel, others give me an "Unable to open file" message. Any help appreciated.
1
1062
by: Michael | last post by:
I have used the following article to try to export from a datagrid into excel http://www.dotnetjohn.com/articles/articleid78.aspx It runs fine for him, but when I try to use it, it just refreshes to a blank page. Any help? Thanks, Michael
1
1481
by: VK | last post by:
Hey, I have some nested datagrids, which I would like to export to a excel. Exporting is not a problem - however I would like to export the nested data into different sheets on the same excel page. Is that possible. Basically I just need to know how to create new sheets in excel. Thanks
3
1662
by: mattdaddym | last post by:
Hi all, I have been using the following code to export my datagrids to excel for quite some time. Very simple and very effective. <code> Sub btnExcelExport_Click ( s As Object, e As EventArgs ) Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
7
4911
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user clicks a button for exporting a datagrid, that the excel file is saved on the server and that it DOES NOT prompt the user to open or save. Here is the code I am using for standard export that prompts the user. Thanks all. Dim...
13
13211
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=ABC.xls") HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.End() However when the user tries to save it the Default File Type is Web Page(*.htm; *.html)
5
2528
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it possible to design an excel template file, place it in my shared network folder and have the procedure write data to the template file? I've thought of reading the recordset line by line, field by field and concatenating an apostrophe at the...
0
8394
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
8306
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
8825
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
8503
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
6164
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
5632
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();...
1
2726
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
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.