By: Rob Fisch | Updated: 2007-07-16 | Comments (12) | Related: > Reporting Services Formatting
Problem
When attempting to display hierarchical data in Reporting Services by using additional spaces, the web browser truncates the additional leading spaces and all data becomes left justified with all of the indentation removed. This is because, like or not, the web browser's job is to compress multiple sequence space characters into one. This may be desired in normal HTML coding, but not so with reporting data. So how can you get Reporting Services to not remove the leading spaces, so you can display your hierarchal tree?
Solution
To take this a step further let's take a look at an example where you would like to display your data as a hierarchy.
For instance, you want your data to look like this:
Rank
Captain
Lieutenant
Sergeant
Corporal
Private
...but when the report is run, Reporting Services displays the data like this:
Rank
Captain
Lieutenant
Sergeant
Corporal
Private
As mentioned above, this is because the web browser's job is to compress multiple sequence space characters into one and therefore all of the leading spaces are removed.
To handle this you can embed a non truncating space character by using an ASCII key combination code. To embed this ASCII key code you would hold the ALT key, type 0160 and then let go of the ALT key.
So to do this for your report, in the Reporting Services table, right click on the textbox with the problem, select (fx) Expression. Then in the Edit Expression editor use the REPLACE function to embed the non-truncating space with the normal one as follows:
=REPLACE(Fields!Rank.Value," "," ") -- (The first value between the double quotes is a space and the second value between the double quotes is the ALT-0160 combination code.)
After you have made this function change and redisplay the report your hierarchy should be displayed properly like the following:
Rank
Captain
Lieutenant
Sergeant
Corporal
Private
Next Steps
- Little formatting tricks like this could be a pain to resolve, but as you see here is simple way to get your report to display properly.
- Take a look at the other Reporting Services tips and stay tuned for more tips
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2007-07-16