Is it possible to disable wrap text in SsRs

Abhishek Srivastava 1 Reputation point
2021-09-13T11:23:40.847+00:00

I have a Ssrs report and I want to download the Ssrs data on excel but the text in any column should not be wrap. Means the text should be visible in a single line.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,849 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Craig Drinnan 6 Reputation points
    2023-11-16T21:59:22.19+00:00

    I searched for a long time for this and never found a solution. I broke down today and wrote one.

    Called with this as the expression for the textbox:

    =Code.FitWidth(Fields!JobComments.Value, 8, 1.523)

    The string to fit ...Value

    The font size

    The width of the text box in inches.

    The Code

    Public Function FitWidth(tempStr as String, iFontSize As Integer, size as Decimal) as String
    Dim bmpImage As New Drawing.Bitmap(1, 1)
    Dim iWidth As Integer = 0
    Dim iHeight As Integer = 0
    Dim temp as String
    
    size = (size * 72) '// I want in units in points
    
    '// Create the Font object for the image text drawing.
    Dim MyFont As New Drawing.Font("Arial", iFontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
    Dim MyGraphics As Drawing.Graphics = Drawing.Graphics.FromImage(bmpImage)
    
    MyGraphics.PageUnit = System.Drawing.GraphicsUnit.Point
    iWidth = MyGraphics.MeasureString(tempStr, MyFont).Width
    iHeight = MyGraphics.MeasureString(tempStr, MyFont).Height
    while (iWidth > size) 
    	temp = Left(tempStr, Len(tempStr)-1)
    	tempStr = temp
    	iWidth = MyGraphics.MeasureString(tempStr, MyFont).Width
    End While
    
    Return tempStr
    
    End Function
    
    There is probably a better way math-wise to do this but it works.
    
    Craig
    
    
    
    1 person found this answer helpful.
    0 comments No comments

  2. Olaf Helper 42,386 Reputation points
    2021-09-13T12:52:55.997+00:00

    Means the text should be visible in a single line.

    Not very clear what you mean? May can you post an example?


  3. Joyzhao-MSFT 15,566 Reputation points
    2021-09-14T01:47:46.117+00:00

    Hi @Abhishek Srivastava ,
    There are CanGrow and CanShrink properties to control the text box expand or shrink vertically based on its contents. However, the CanGrow property only indicates that the text box height can increase to accommodate the contents but not the width.

    By design, width of textbox or table column is always static. So, in order to prevent the word wrapping, please increase the width of the column if possible.

    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Cory Schultze 1 Reputation point
    2022-02-25T11:14:08.3+00:00

    I know this is a bit late but I get around this by adjusting the Top and Bottom Padding and setting the Can Grow property to False.
    The only problem is, if the string is too long to display, it trims at the space and moves the remainder of the string to the next line, which is not displayed.

    The O.P. Wanted something like:
    THIS IS A STRING THAT I WANT TO TRUNCATE
    To appear in a fixed-width column as:
    THIS IS A STRING THAT I WANT T
    Instead of:
    THIS IS A STRING THAT I WANT
    TO TRUNCATE
    With SSRS and my suggested solution, you would get:
    THIS IS A STRING THAT I WANT

    Sadly, this is less effective with longer words. I feel that the community would like a behaviour similar to Excel, where the text within a cell is simply printed right up to the beginning of the next cell (providing it is not empty).
    |Text in cell 'A' goes up to he|Text in cell 'B' goes up to here because it's a wider column. |Cell 'C' |

    I hope that's enough examples to demonstrate the intention.

    0 comments No comments

  5. Tom Dale 1 Reputation point
    2022-07-14T23:02:46.113+00:00

    Has there been any other updates on this subject? We tried the can grow/shrink properties but it does not work.

    0 comments No comments