Logo
My activities

Convert RTF to Plain Text in SSRS

Though SQL Server Reporting Services (SSRS) only displays plain text, it's possible to convert the rich text (RTF) fields in the WRM database into plain text, which then allows you to include those fields in your report. This is done by adding a custom code to the report, then adding an expression for each RTF field you wish to display as plain text.

To convert RTF to plain text in a report:

  1. Open the report in SSRS.
  2. Right-click the blue space on the report, then select Report Properties.
  3. Click Code in the left pane.
  4. Enter the following code in the text box:

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

    Dim returnValue As String = String.Empty

    try

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

    converter.Rtf = input.Trim

    returnValue = converter.Text

    End Using

    Catch

    returnValue =input

    End Try

    Return returnValue

    End Function

  5. Click References in the left pane.
  6. Click Add below Add or remove assemblies.
  7. Enter the following code in the text box:

    System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

  8. Click OK
  9. Repeat steps 2-8 above for each report that will need RTF fields converted to plain text.
  10. Add the field you wish to convert from RTF to plain text to the appropriate report.
  11. Right-click the field, then click Expression.
  12. Add the following expression (replacing FieldName with the name of your field):

    =Code.ConvertRtfToText(Fields!FieldName.Value)

  13. Repeat steps 10-12 above for each field you wish to convert.
Follow
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request
Powered by Zendesk