Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 SSRS 2005 Custom rendering.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-11 : 07:27:00
Dan writes "I created a custom rendering extension that just returns a test message to the rendering stream.

Dim s As System.IO.Stream = createAndRegisterStream( _
"Test", "txt", System.Text.Encoding.UTF8, "text", True, _
Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister)

Dim sw As New System.IO.StreamWriter(s)

sw.Write("Testing")
''For i As Integer = 0 To report.Body.ReportItemCollection.Count - 1
''sw.WriteLine(RenderReportItem(report.Body.ReportItemCollection(i)))
'sw.Write("Test")
'sw.Write("</body></html>")
''Next
sw.Close()
's.Close()
Return True


If i don't close the stremwriter it creates the file but does not write to it. If I close the streamwriter I get an error "Cannot access a closed Stream"

Any ideas?

Thanks,

Dan"

dleonelli
Starting Member

2 Posts

Posted - 2005-12-02 : 15:06:22
quote:
Originally posted by AskSQLTeam

Dan writes "I created a custom rendering extension that just returns a test message to the rendering stream.

Dim s As System.IO.Stream = createAndRegisterStream( _
"Test", "txt", System.Text.Encoding.UTF8, "text", True, _
Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister)

Dim sw As New System.IO.StreamWriter(s)

sw.Write("Testing")
''For i As Integer = 0 To report.Body.ReportItemCollection.Count - 1
''sw.WriteLine(RenderReportItem(report.Body.ReportItemCollection(i)))
'sw.Write("Test")
'sw.Write("</body></html>")
''Next
sw.Close()
's.Close()
Return True


If i don't close the stremwriter it creates the file but does not write to it. If I close the streamwriter I get an error "Cannot access a closed Stream"

Any ideas?

Thanks,

Dan"

Go to Top of Page

dleonelli
Starting Member

2 Posts

Posted - 2005-12-02 : 15:08:37
OOPS!

Flush the stream

sw.flush
Go to Top of Page

kmyothwe
Starting Member

1 Post

Posted - 2009-03-31 : 22:17:43
thanks a lot !
Confirm

sw.flush()
It is work .


Go to Top of Page

EricG
Starting Member

2 Posts

Posted - 2012-05-10 : 07:20:55
Hey,

I don't get it. What is it supposed to look like?

Public Function Render(ByVal report As Microsoft.ReportingServices.OnDemandReportRendering.Report, ByVal reportServerParameters As System.Collections.Specialized.NameValueCollection, ByVal deviceInfo As System.Collections.Specialized.NameValueCollection, ByVal clientCapabilities As System.Collections.Specialized.NameValueCollection, ByRef renderProperties As System.Collections.Hashtable, ByVal createAndRegisterStream As Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream) As Boolean Implements Microsoft.ReportingServices.OnDemandReportRendering.IRenderingExtension.Render

Dim s As Stream = createAndRegisterStream(report.Name, "htm", System.Text.Encoding.UTF8, "text/html", True, Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister)
Dim sw As New System.IO.StreamWriter(s)

sw.WriteLine("<html><body><div>CustomHTML..</div>")
sw.WriteLine("<script>alert</script>")
sw.WriteLine("</body></html>")

sw.Flush()
sw.Close()
s.Close()
Return False
End Function

Results in the error still.
I moved the flush function after its initialization, nothing really works (I'm not quite a VB expert).
Go to Top of Page

EricG
Starting Member

2 Posts

Posted - 2012-05-10 : 07:43:50
I moved the flush function call**

What worked for me:

Public Function Render(...) As Boolean Implements Render

Dim s As Stream = createAndRegisterStream(report.Name, "htm", System.Text.Encoding.UTF8, "text/html", True, CreateAndRegister)

Dim sw As New System.IO.StreamWriter(s)
'sw.AutoFlush = True

sw.WriteLine("<html><body><div>CustomHTML..</div>")
sw.WriteLine("<script>alert()</script>")
sw.WriteLine("</body></html>")

sw.Flush()

'sw.Close()
's.Close()
Return False
End Function
Go to Top of Page
   

- Advertisement -