After a bit of experimentation, I’ve found a technique I like to use for handling white space in SSRS 2008 R2 when a textbox is hidden.
Let’s say we have a textbox that shouldn’t be displayed – for example, sometimes I like to leave annotations in the report. Annotations aren’t built into SSRS like they are in SSIS, but can easily be done with a textbox. The kicker though is that even if you hide the textbox, SSRS will have whitespace which isn’t something you want even at the bottom of a report.
Another typical use for a textbox that always remains hidden is to perform a calculation within it, and then refer to that textbox later in other expressions using the ReportItems collection.
Using a Hidden Textbox: Has White Space Issue
Pretend for a moment here that this report is much more complex and, due to its size, the placement of hidden textbox is really important. In this example I’ve placed it between the report title and the report content in the tablix. If we just use a textbox placed on the body of the report, we are left with white space issues.
Sidenote about the yellow color: When I hide something in the report (and it’s always intended to be hidden), I typically use a fill color of pale yellow – this is my personal indication that it’s hidden & serving some other purpose.
Design View in BIDS:
Preview in BIDS (not what we want):
There is a Report property called “ConsumeContainerWhitespace” which is set to false by default. Setting this property to true does not resolve the above issue (its job is to prevent a blank page at the end of the report).
Using a Tablix With Column or Row Visibility Set to False: Resolves the White Space Issue
A slight variation of the above will fix the issue. Instead of placing the textbox directly on the body of the report, place a tablix on the body with the textbox in it. Then, set the ColumnVisibility (or RowVisibility) property to false. Voila! Using Column or Row Visibility set to false does remove the vertical white space (whereas the above Hidden property on the textbox did not).
Design View in BIDS:
Preview in BIDS (looks much better!):
A couple of comments about using a tablix in this manner:
- Even if it only contains a textbox with annotations (i.e., and isn’t retrieving any data), it still needs to be associated to a dataset or you’ll receive an error.
- I delete the detail row (and its associated group, when prompted), and only use the header row of the tablix. I also delete any unneeded columns.