SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Reporting Services Development
 SSRS 2005 Custom rendering.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 11/11/2005 :  07:27:00  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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 - 12/02/2005 :  15:06:22  Show Profile  Reply with Quote
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 - 12/02/2005 :  15:08:37  Show Profile  Reply with Quote
OOPS!

Flush the stream

sw.flush
Go to Top of Page

kmyothwe
Starting Member

1 Posts

Posted - 03/31/2009 :  22:17:43  Show Profile  Reply with Quote
thanks a lot !
Confirm

sw.flush()
It is work .



Edited by - kmyothwe on 03/31/2009 22:18:59
Go to Top of Page

EricG
Starting Member

2 Posts

Posted - 05/10/2012 :  07:20:55  Show Profile  Reply with Quote
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 - 05/10/2012 :  07:43:50  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000