Export DataGrid to Excel problem

G

Guest

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
 
G

Guest

try this...

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

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

oHtmlTextWriter.Write("<style>")
oHtmlTextWriter.Write(".dataGridHeader{font-weight: bold;font-size:
8pt;color: black;font-family: Verdana;background-color: #ddddee;text-align:
left;}")
oHtmlTextWriter.Write(".dataGridItemStyle{font-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.RenderControl(oHtmlTextWriter)


oHtmlTextWriter.Write("</form></body></html>")
Response.Write(oStringWriter.ToString())
Response.End()

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top