Rich text in SSRS 2008

One of the most irritating and common requirements that I faced as a developer in SSRS 2005 was when I had to colour words in the same line differently. Even though SSRS 2005 didn’t provide an inbuilt feature to do this, this could always be done by placing the words in different textboxes.

Suppose I had a title as

Category = Accessories and Order Count = 19523

where Accessories and 19523 are retrieved from the dataset, and if I just wanted them in a single colour, I could write the below expression in a textbox.

=”Category = “+Fields!Category.Value+” and Order Count = “+Fields!Order_Count.Value

The hassle was when the customer gave the requirement that the values should be in a different colour and in bold. Now for this, we need to break the expression into different parts such that only consecutive words of the same colour appear in one textbox. Hence, the above expression had to be broken down into 4 textboxes:-

1) Category =

2) Fields!Category.Value

3) and Order Count =

4) Fields!Order_Count.Value

and then each textbox could be given it’s own property.

simulating rich text in SSRS 2005

This would prove to be very annoying for the developers especially if the sentence was a very long one which had alternating colours in between.

Preview of rich text in SSRS 2005

Also, unless you painstakingly spend hours in it, the spacing would not be 100% accurate. For eg, if you see in the above image, you can notice that spacing between the words is not uniform

But with the advent of SSRS 2008, this issue is a matter of the past. Now you can directly type in your sentence and/or drag and drop the fields from the dataset or the report parameters. To change the properties of the required text, just highlight the part and then press F4 to view the property panel of the selected text.

Rich text in SSRS 2008

In the example above, I have highlighted the [Category] text. Notice how the property panel displays Selected Text, and not the name of the textbox. Now you can change the properties as you like be it the colour, indentation, font, etc. Another thing to notice is that instead of displaying <<Expr>>, we can actually see the words and the Field names have a placeholder. Eg, for Fields!category.Value, we actually see [Category]. Also see below how neat the result looks compared to what we had in 2005.

Preview of rich text in SSRS 2008

This can be extended to objects like tables and matrixes also. In SSRS 2005, if it was required to have a column partially bold or coloured, we had to make different textboxes and then enclose them within a rectangle. Then the rectangle could be used in the matrix.

Table in Design mode - SSRS 2005  Table in preview mode - SSRS 2005

In SSRS 2008, you can just select the required text and edit as mentioned in the previous section.

Matrix in Design Mode - SSRS 2008 Table in preview mode - SSRS 2008

It is small features like this which makes me an ardent fan of SSRS 2008.