By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,905 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,905 IT Pros & Developers. It's quick & easy.

Export DataGrid to Excel problem

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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__
---_,>/'_------
(_) \(_)
---------------
"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

P: n/a
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**********************************@microsof t.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

P: n/a
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**********************************@microsof t.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 discussion thread is closed

Replies have been disabled for this discussion.