SSRS Report Templates

In this post I will outline a very simple approach to creating a report template for your SSRS solution.

Getting Started

Create a new (or open an existing) reporting solution and add a new report, let’s call it _Template.rdl – this report will form the basis of our template.

Open this report and add any standard formatting or style that you want for all future reports. Maybe you have standard header/footers, e.g. all titles need to be blue and there should be a footer which shows the date the report was produced.

My template looks like this:

SSRS Sample templateHere you can see that I’ve added a header and footer, in the header I’ve added the ReportName built-in field into a textbox and applied some formatting to it.

The idea being that all future reports should use this template. Now, we could just instruct all the report developers that they need to open this file from the solution make some changes then do a “Save As”.  But  this is not exactly ideal.

Report Templates

Instead what we want is for this template to appear in the Add New Item dialogue which appears when the user right clicks Reports and selects Add New Item.

Add New Items

After some quick googling, you will soon discover that all we need to do is copy our template into a directory in the Visual Studio directory in Program Files:

For VS2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

For VS2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

This would be a good start, however what happens when the template is updated by another developer and checked into source control? The next time someone else does a “Get Latest” they will need to check if the Template has been changed and remember which directory to copy this file into.

A better way is to use symbolic links. In Windows this is achieved using the mklink command (http://technet.microsoft.com/en-us/library/cc753194(v=ws.10).aspx)

mklink "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject\My Report Template.rdl" "C:\dev\Reporting\_Template.rdl"

You can execute this from command prompt, just be aware that you will need to be running it as Administrator.

After running this command open the Add New Items dialogue, and you will see the new report appear as a template:

SSRS-Templates-3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s