locked
Insert Line Breaks In a paragraph RRS feed

  • Question

  • Hi

    I'm using SSRS to create a requisition for a company. One of the fields is the description which can be quite long.

    They want to be able to cut and paste the description (line by line) into another program, but the length of each line needs to be no more than 30 characters.

    How can I loop through the description and insert a line break every 30 characters?

    Thanks for any help!
    Monday, May 4, 2009 3:16 PM

Answers

  • If you're using SSRS2008, you can use the Rich Formatting with MarkupType=HTML http://msdn.microsoft.com/en-us/library/cc627491.aspx to create a textbox with multiple paragraphs.

    Hope this helps, Jamie
    • Marked as answer by Raymond-Lee Friday, May 15, 2009 4:07 AM
    Tuesday, May 5, 2009 4:06 AM
    Answerer
  • Hi

     

    And if you are using Reporting Services 2005, you can try the below steps:

    1)    Copy the below code into the code tab in Report Properties menu:

    Function MyFunc(ByVal str As String) As String()

    Dim c() As String

    Dim s As String

     Dim i As Integer

    Dim j As Integer

    j = 1

    For i = 1 To Len(str)

    s = Mid(str, i, 30)

    ReDim Preserve c(j- 1)

    c(j - 1) = s

    j = 1+j

    i= 29+i

    Next

    MyFunc = c

    End Function

    2)    Using the expression like this to insert a line break for a certain field:

    =join(code.MyFunc(=Fields!description.Value),Chr(10))

     

    In this way, the string will display like this:

    1……….30

    31……..60

    61………90

     

    But I still suggest you should using drill through report to display the long string field.

     

    Hope this helps.

    Raymond

     

    • Marked as answer by Raymond-Lee Friday, May 15, 2009 4:07 AM
    Wednesday, May 6, 2009 4:38 AM

All replies

  • If you're using SSRS2008, you can use the Rich Formatting with MarkupType=HTML http://msdn.microsoft.com/en-us/library/cc627491.aspx to create a textbox with multiple paragraphs.

    Hope this helps, Jamie
    • Marked as answer by Raymond-Lee Friday, May 15, 2009 4:07 AM
    Tuesday, May 5, 2009 4:06 AM
    Answerer
  • Hi

     

    And if you are using Reporting Services 2005, you can try the below steps:

    1)    Copy the below code into the code tab in Report Properties menu:

    Function MyFunc(ByVal str As String) As String()

    Dim c() As String

    Dim s As String

     Dim i As Integer

    Dim j As Integer

    j = 1

    For i = 1 To Len(str)

    s = Mid(str, i, 30)

    ReDim Preserve c(j- 1)

    c(j - 1) = s

    j = 1+j

    i= 29+i

    Next

    MyFunc = c

    End Function

    2)    Using the expression like this to insert a line break for a certain field:

    =join(code.MyFunc(=Fields!description.Value),Chr(10))

     

    In this way, the string will display like this:

    1……….30

    31……..60

    61………90

     

    But I still suggest you should using drill through report to display the long string field.

     

    Hope this helps.

    Raymond

     

    • Marked as answer by Raymond-Lee Friday, May 15, 2009 4:07 AM
    Wednesday, May 6, 2009 4:38 AM