473,566 Members | 2,847 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 4341
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
5883
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
3000
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...
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
2460
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...
3
1660
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
2915
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
1463
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
2525
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...
1
1205
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...
0
7584
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...
0
7888
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. ...
0
8108
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...
1
7644
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...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
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...
0
5213
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...
0
3643
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...
0
925
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...

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.