473,695 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export DataGrid to Excel problem

When i export DataGrid to Excel all the HTML contents are also exporting to
excel. i am using stylesheets in the ASPX Page and i am getting an alert
message that stylesheets are missing. i need to export only the contents of
the Datagrid to excel. i don't need all other stuff which is present on the
page. is there any way to achieve it.

Thanks in Advance
Nov 19 '05 #1
3 4349
try this...

Response.Clear( )
Response.Buffer = True
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.Charse t = ""
Dim oStringWriter As New System.IO.Strin gWriter
Dim oHtmlTextWriter As New System.Web.UI.H tmlTextWriter(o StringWriter)

oHtmlTextWriter .Write("<html>< head>")

oHtmlTextWriter .Write("<style> ")
oHtmlTextWriter .Write(".dataGr idHeader{font-weight: bold;font-size:
8pt;color: black;font-family: Verdana;backgro und-color: #ddddee;text-align:
left;}")
oHtmlTextWriter .Write(".dataGr idItemStyle{fon t-size: 8pt;color:
black;font-family: Verdana;text-align: left;}")

oHtmlTextWriter .Write("</style>")
oHtmlTextWriter .Write("</head><body>")

oHtmlTextWriter .WriteBeginTag( "form runat=server ")
oHtmlTextWriter .WriteAttribute ("target", "_blank")
oHtmlTextWriter .Write(">")
dgReport.Render Control(oHtmlTe xtWriter)
oHtmlTextWriter .Write("</form></body></html>")
Response.Write( oStringWriter.T oString())
Response.End()

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"Bidarkota" wrote:
When i export DataGrid to Excel all the HTML contents are also exporting to
excel. i am using stylesheets in the ASPX Page and i am getting an alert
message that stylesheets are missing. i need to export only the contents of
the Datagrid to excel. i don't need all other stuff which is present on the
page. is there any way to achieve it.

Thanks in Advance

Nov 19 '05 #2
Well that depends on what technique you are using to export the datagrid.
There are a variety of ways to export ASP.NET content to Excel.
Most of the techniques are described in detail here:
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/articles/ExcelExport.aspx

These examples remove all the extra HTML "stuff" you're talking about.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Bidarkota" <pr******@yahoo .com> wrote in message
news:DC******** *************** ***********@mic rosoft.com...
When i export DataGrid to Excel all the HTML contents are also exporting
to
excel. i am using stylesheets in the ASPX Page and i am getting an alert
message that stylesheets are missing. i need to export only the contents
of
the Datagrid to excel. i don't need all other stuff which is present on
the
page. is there any way to achieve it.

Thanks in Advance

Nov 19 '05 #3
Thank you vinay and Steve. My problem is solved.

"Steve C. Orr [MVP, MCSD]" wrote:
Well that depends on what technique you are using to export the datagrid.
There are a variety of ways to export ASP.NET content to Excel.
Most of the techniques are described in detail here:
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/articles/ExcelExport.aspx

These examples remove all the extra HTML "stuff" you're talking about.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Bidarkota" <pr******@yahoo .com> wrote in message
news:DC******** *************** ***********@mic rosoft.com...
When i export DataGrid to Excel all the HTML contents are also exporting
to
excel. i am using stylesheets in the ASPX Page and i am getting an alert
message that stylesheets are missing. i need to export only the contents
of
the Datagrid to excel. i don't need all other stuff which is present on
the
page. is there any way to achieve it.

Thanks in Advance


Nov 19 '05 #4

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

Similar topics

6
5888
by: Eric | last post by:
Dear All, I want to export datagrid content to a Excel file, the code just like below: Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) gridList.Columns(0).Visible = False
9
3007
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.
2
395
by: C | last post by:
Hi, I have a dataset which I bind to a datagrid on my ASPX. I then export the datagrid to Excel and stream the file to the user by setting the MIME Type etc etc. Response.ContentType = "application/vnd.ms-excel";
2
2469
by: Bidarkota | last post by:
Hi, I have a DataGrid in which there are some images and Data are displayed and in the webform.asp page i am using some stylesheets. when i export the datagrid all the images are also exported to datagrid and it is giving an alert that following stylesheets are missing when i export it. can anyone help me about this problem. I have seen the sites and articles regarding the datagrid export to excel. but still i am getting the same...
3
1667
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")
0
2925
by: kieran | last post by:
Hi, I have an 'export to excel' button on my Datagrid. All works well except that on my Datagrid, I have sub total rows. The subtotal rows use colspan so that the subtotals are given above certain columns When I export to excel, I do not have the colspan. As a result, the subtotals appear over the wrong columns in Excel.
0
1473
by: madhavit | last post by:
hi, i am able to export datagrid data to excel sheet but the problem is i am not able to export datagrid within datagrid data to excel. can anybody help me. thanx.
5
2531
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...
1
1208
by: Reggie | last post by:
Hi and TIA! I have a datagrid inside a panel control. I have a procedure that exports the panel control and thus the datagrid to excel. The datagrid has the following sample fields/data. Nomen NIIN Qty Key 000234567 2 Ring 002818181 3 The problem is that I loose the leading zero's. How can I update the dataset to concatenate an apostrophe to the beginning of each NIIN...
0
9140
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
9004
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
8864
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
7685
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
6510
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
5843
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
4351
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
3025
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
3
1987
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.