Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Column Width growing, Text not wrapping

Tags:

ssrs-2008-r2

I am creating a report with SSRS, SQL Server 2008-R2. The report has a few matrices, each with the same number of columns, pulling data from different data sets, to give the appearance of a single table. When I render the report in VS, the columns look fine. Columns with long strings of text wrap the text, and the columns stay in alignment. This is the behavior I want from the report. However, when I run the report from a browser (IE or Firefox), the text does not wrap, and the column width expands to fit the text on a single line. This leaves the report with columns of different size, when they should be the same. Is there a way to force the text to wrap and prevent the column width from expanding? I tried the "Can Grow" property, but it looks like that applies only to height, not width

like image 967
user1873604 Avatar asked Apr 14 '14 15:04

user1873604


2 Answers

Just double click the field in the grid (or textbox). It will open up a pop up window. Under 'General' tab change 'Markup type' from 'None - plain text only' to 'HTML - Interpret HTML tags as Style.

like image 53
N Rocking Avatar answered Sep 18 '22 07:09

N Rocking


It looks like SSRS team has tried to implement word-breaking, but didn't complete it. I assume so as they actually render:

<div style="word-wrap:break-word;white-space:pre-wrap;" 
     class="A28f9f53b98ae45d6a21919d29df775da131">Text </div>

but they miss word-break property in their markup. (or is css broken as it requires both word-wrap:break-word does not work? :) here is a nice investigation on the subject )

Anyway, to break text in columns, add the following css to your page with report viewer:

    div [style*="break-word"] {
        -ms-word-break: break-all;
        word-break: break-all;
        /* Non standard for webkit */
        word-break: break-word;
    }

NB: this will NOT break text in column headers (I prefer setting column headers line-breaks manually as the text is fixed and known in design-time).

like image 33
Isantipov Avatar answered Sep 21 '22 07:09

Isantipov