473,385 Members | 1,912 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.

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.ContentType = "application/download"
Page.EnableViewState = False
resp.Charset = String.Empty
resp.AppendHeader("Content-Disposition",
"attachment;filename=ContainerReport.xls")
Dim colHeaders As String

Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

DG.RenderControl(hw)
----------------------------------------------------
Thanks!
John
Nov 21 '07 #1
1 1295
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.ContentType = "application/download"
Page.EnableViewState = False
resp.Charset = String.Empty
resp.AppendHeader("Content-Disposition",
"attachment;filename=ContainerReport.xls")
Dim colHeaders As String

Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

DG.RenderControl(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
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,...
0
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. ...
9
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...
1
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...
1
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...
3
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...
7
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...
13
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"...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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...

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.