Have you ever struggled with creating tabs in a Reporting Services report? If you have, you will most likely know that Reporting Services does not contain any controls to accomplish this out of the box. Finding a suitable solution can be tricky!
In this post I will show a possible solution for implementing a tab navigational structure in SSRS. This will be accomplished by using textboxes with background images representing the tabs.
Bookmarks and actions will be used to link the tabs to their appropriate report section and the RepeatWith property is used to repeat the tabs on each page. By conditionally hiding the tabs and setting page breaks exporting to Excel and PDF will still look nice ;).
The result will look like the image below, were clicking a tab will display the corresponding report section. A sample report can be found here (Sample runs on the AdventureWorksDW2012 database).
On to the implementation!
Below I’ll provide a step by step guide showing you how to implement this solution. I’ll do this by developing a demo report based on AdventureWorksDW2012 that will meet the following requirements:
– The report will contain three sections that must be navigable by tabs
– The tabs must be available at every report page
– Exporting to Excel and PDF must be supported
– When exporting to Excel the tabs must be replaced by Worksheets
– When exporting to PDF the tabs must be hidden
Step 1: Creating the first tab
The first step is finding or creating suitable images for your tabs, creating the report and developing your first tab:
– Create a new report and add a rectangle to it. Place three textboxes inside this rectangle. Type the names of the tabs in the text area of these textboxes.
– Acquire two images to represent the tabs. One for the unselected tabs and one for the selected tab.
I used these images to represent my tabs:
– Right click “Images” in the Report Data window and add the images to the newly created report.
– Set the BackgroundImage property of the leftmost tab to the selected tab image. Then set the BackgroundImage property for the other two textboxes to the unselected tab image.
– Resize the textboxes to fit the image.
– Add the first tab’s content underneath the rectangle (for demo purposes I’ll display a table displaying employees and the amount they’ve sold).
– Add a page break after the end of the content.
After this step your report should look similar to the image below:
Step 2: Creating the second and third tab
Creating the second and third tab is almost the same as creating the first. Repeat these steps for each tab you wish to add:
– Place a rectangle underneath the previous tabs content.
– Add textboxes to this rectangle and set their background image property appropriately.
– Add the tab’s content beneath the rectangle and add a page break at the end of the content.
After this step our report will look like this:
Step 3: Creating bookmarks and actions for navigation
In this step we will create the logic that will cause that clicking a tab will display the corresponding content.
– Set a logical name for the bookmark property for the three rectangles containing the tabs.
– Set the Action property for all the tab textboxes to: “Go to bookmark” and set it to the corresponding bookmark you want this tab to refer to.
Clicking on the tabs in our report will now cause it to show the corresponding report part.
Step 4: Repeat the tabs for larger report sections
Our third tab still contains one problem: The pages after the first one will not display the Tabs. This can be fixed by using the RepeatWith property. This property will cause a report item to be repeated on each page that is created by the object that the property is set to.
– Set the RepeatWith property of the third tab’s rectangle to the name of the tablix on the third tab.
Step 5: Exporting the report
To make exporting to Excel and PDF look nice we will need to hide the tabs when we are not in “Interactive Mode”. Also we need to set up Page Names so that in Excel the tabs will be represented by worksheets.
– Add the following expression to the hidden property to each rectangle
=Globals!RenderFormat.IsInteractive = FALSE
– Set the Page Name property of each tablix to the name of its tab.
That concludes my first blog post on this community. I hope that you found it useful. And please, leave any suggestions and/or experiences you want to share in the comments below!