Standardizing and Centralizing Report Design (or: creating style sheets for reports) Part 3: The Style-Template

In the first part we learned how to integrate a Layout-Template into BIDS. The second technique in this series we are looking at will be using the “Style-Template”.

What is a Style-Template?:

Style-Templates are a set of definitions such as font size, font type, font color, background color, border styles, etc., which is being used from within the “Add New Report” wizard inside Business Intelligence Development Studio.

Report Layout-Templates are shown in the Project-Dialogue “Add“ – “New Item“ .

image

This is where you usually chose among those beautiful styles, that Microsoft provides you with (Slate, Forest, Corporate, Ocean, Bold, Generic) Open-mouthed smile.

image

But: you can include your own style definition!

And this is how we can create a Style-Template:

1) Open the file StyleTemplates.xml from the following location (watch for your locale specific folder at the end) using your favorite XML Editor (notepad is sufficient):

for Reporting Services 2005

•%ProgramFiles%\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\Business Intelligence Wizards\Reports\Styles\en

for Reporting Services 2008 x64

•%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Business Intelligence Wizards\Reports\Styles\en

for 32-bit Reporting Services 2008

  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Business Intelligence Wizards\Reports\Styles\en

2) I strongly advice you create a backup of StyleTemplates.xml before you edit it:

3) Look for a complete “StyleTemplate”-node like “<StyleTemplate Name="Slate"> … </StyleTemplate>” and copy it to the end, just before the Generic-Style (<StyleTemplate Name="Generic">)

4) Rename the copied definition

5) Now you can start changing colors, border styles, fonts etc.

You will find out, that not everything will be accepted. There is no documentation and so far this is what I can give you as a set of rules I found out the hard way – hope it helps saving you time:

Rules of engagement for producing a Style-Template:

  • Backup StyleTemplates.xml before editing it!
  • Watch out for whitespaces and line breaks. Otherwise you will get Error messages such as “Red is not a valid color”.
  • Not all Attributes are supported and give you an error when running the wizard.
    • I.e. <TopBorder> etc.
  • Some fail silently like “<BorderWidth>”
  • Color values have no spaces between words
    • “Dark Olive Green” is coded “DarkOliveGreen”
  • Font names can include spaces
    • <FontFamily>Times New Roman</FontFamily>
  • TextAlign does not work in "Table Header" – sometimes align in header rows is out of order for no reason
  • default font for table does not work here either

Sample Style-Template code:

<StyleTemplate Name="Pizza_Time">
    <Label>Pizza_Time</Label>
    <Styles>
        <Style Name="Title">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>20pt</FontSize>
            <Color>Red</Color>
            <TextDecoration>Underline</TextDecoration>
        </Style>
        <Style Name="Page Group Level 1">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>14pt</FontSize>
        </Style>
        <Style Name="Page Group Level 2">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>12pt</FontSize>
        </Style>
        <Style Name="Page Group Level 3+">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>10pt</FontSize>
        </Style>
        <Style Name="Table"></Style>
        <Style Name="Matrix"></Style>
        <Style Name="Table Header">
            <BackgroundColor>Tomato</BackgroundColor>
            <FontFamily>Tahoma</FontFamily>
            <FontSize>11pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>White</Color>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
        <Style Name="Group Level 1">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>11pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>DarkOliveGreen</Color>
            <BackgroundColor>Wheat</BackgroundColor>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
        <Style Name="Group Level 1 Textbox">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>11pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>DarkOliveGreen</Color>
            <BackgroundColor>Wheat</BackgroundColor>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
        <Style Name="Group Level 2">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>10pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>DarkOliveGreen</Color>
            <BackgroundColor>LightSalmon</BackgroundColor>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
        <Style Name="Group Level 2 Textbox">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>10pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>DarkOliveGreen</Color>
            <BackgroundColor>LightSalmon</BackgroundColor>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
        <Style Name="Detail">
            <FontFamily>Tahoma</FontFamily>
            <FontSize>10pt</FontSize>
            <FontWeight>Bold</FontWeight>
            <Color>White</Color>
            <BackgroundColor>LimeGreen</BackgroundColor>
            <BorderStyle>
                <Default>Solid</Default>
            </BorderStyle>
            <BorderColor>
                <Default>DimGray</Default>
            </BorderColor>
        </Style>
    </Styles>
</StyleTemplate>

You can of course include several sets of Style-Templates.

How to test?

Just run the “Add new Report”-wizard from inside BIDS, and you will see your own style appear in the list. Unfortunately there will be no picture-preview for user defined styles, so use a descriptive name.

image

And again, just like the Layout Templates, you could xcopy deploy this folder to all your Developers machines.

How about “centralizing”?

  • Just as Report Layout Templates you can “xcopy deploy” this folder regularly to all your Developers machines.
  • But again: once the reports are created, and you make a change to the originating template, existing reports will not be touched.

How about “standardizing”?

  • If you “xcopy deploy” this folder regularly to all your Developers machines, all developers can easily use the same colors and fonts for newly created tables & matrixes.

In short: What Style-Templates can be used for:

  • If you like using the „New Report“-wizard for quickly starting a report:
  • Have the first Table or Matrix finalized with the corporate-design colors and font-styles
  • Includes a report-title and body-color

Note:

  • Does NOT apply to elements added thereafter
  • Once the report is created, the style is hard-coded

 

References:

the only reference with code samples on the web is this post from 2004 here by a Microsoft guy:
http://www.ms-news.net/f3037/styletemplates-xml-tags-2920674.html#post9344712

The second link I’ll provide just gives a general overview over the two methods “Report (Layout) Template” and “Report Style Template”:
http://blogs.microsoft.co.il/blogs/yanivy/archive/2010/08/03/create-custom-templates-and-styles-for-ssrs-2008.aspx

 

In the next Part of the series, I will show how to use custom code for managing style.

Andreas

Sarpedon Quality Lab

No feedback yet
Leave a comment

Your email address will not be revealed on this site.

Your URL will be displayed.
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
Bitte geben Sie den Namen dieser Domäne ohne http://www., aber mit Endung ein?
Please answer the question above.