I have read a post or two on other messageboards from people who said that they have done it, and I also heard from a Microsoft source that this is a perfectly acceptable way of capturing an HTML output since MS removed that export capability before they released the control.
What I'm asking to be done could probably be done on any web control that renders HTML, I just don't know how to do it in the general sense (steal the rendering stream from a web control and save the stream off to a file.)
Hopefully what I said makes sense.
If anyone has any suggestions on how to handle that, I would greatly appreciate it.
Thanks,
Ken
Ken, this gets the report output in a stream, I assume you can take it from there. I found this as an example of someone converting to excel(note the commented out line). So I have not really tested this, I just wanted to help.
Response.Clear()
Response.Buffer =True
' Response.ContentType = "application/vnd.ms-excel"
Response.ContentType = "text/html"
Response.Charset = ""
Dim oStringWriterAsNew System.IO.StringWriter
Dim oHtmlTextWriterAsNew 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(">")
ReportViewer1.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.Write("</form></body></html>")
Response.Write(oStringWriter.ToString())
Response.End()
sql
No comments:
Post a Comment