locked
word report with rtf text RRS feed

  • Question

  • Hello
    In my database I have rtf strings. How can I get this as formatted text into a word report?

    Thank you
    wima
    Friday, February 5, 2010 10:47 AM

All replies

  • Hi Marco,

     

    To display the RTF strings as formatted text into a word report, you can use the custom code to do this conversion. I assume you are running Reporting Service 2008.  The following are the detailed steps to achieve this:

    1.       On the report design, click the menu “Report” and select “Report Properties”, it will pop up the Report Properties dialogue box, in the box, click “Code” and type the following custom code in the code box:

     

    Public Shared Function ConvertRtfToTxt(ByVal input As String) As String

     

    Dim returnValue As String = String.Empty

     

    Using converter As New System.Windows.Forms.RichTextBox()

    converter.Rtf = input.Trim

    returnValue = converter.Text

    End Using

     

    Return returnValue

     

    End Function

     

    2.       The above custom code runs within referencing the namespace “System.Windows.Forms”.  In the Report Properties dialogue box, click “References” at the left hand panel, then click “Add” to add the this namespace from the .net component name list.

    3.       Specify a domain account for unattended report processing in the Execution Account page of Reporting Services Configuration Manager tool. Access http://msdn.microsoft.com/en-us/library/ms156302.aspx for configuring the unattended execution account.

    4.       The reporting services set the default permission of report expressions to “Execution” for security reasons. But the above code need more permissions to execute. So, please locate the report server file rssrvpolicy.config( by default, it is stored at C:\Program Files\Microsoft SQL Server\MSRS10.JNMSSQLSERVER\Reporting Services\ReportServer\) and open it with Visual studio to update the permission of the following code groups to be “FullTrust”:

    <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="Report_Expressions_Default_Permissions" Description="This code group grants default permissions for code in report expressions and Code element. ">


       
    <CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="FullTrust" Description="This code group grants MyComputer code Execution permission. ">

    After these steps, the RTF string should be able to be converted into text on your report.

     

    Please let us know if you have more question.

     

    Thanks,

    Jerry
    Tuesday, February 9, 2010 2:13 AM
  • Hello

    This does not work. This puts the unformatted text into word. I think the returnValue of this function is a String. Shouldn't be a formatted string?

    Thanks
    wima
    Wednesday, February 10, 2010 12:17 PM