您的位置:首页 > 数据库

SSRS的一些格式问题

2014-05-23 21:26 525 查看

Getting Started Formatting SSRS Reports

By
Franco Lopes
Formatting SSRS Report

Introduction

The SSRS report once ready  needs to beformatted to make it pixel perfect for viewing and printing. The formatting canbe classified into the following types:

Conditional Formatting
Unconditional Formatting

ConditionalFormatting

The conditional formatting  is doneusing the  IIF and  switch  statements. For conditional formattingcan be used to display the alternate rows with the specific color codes.

UnconditionalFormatting

Unconditional formatting can be usedto format the report for the date and number values in a report. For example displaying the date in theIndian format, with the default date is displayed in the US format.

 ImplementingFormatting in SSRS Report

Let work thorugh a sample report formatting exercise.I created a sample report whose output is below.As you can see the report is just the raw draft of the requirements given tothe developer but still not in the state to present it to the end businessuser
and also lacks the basic formatting for the displaying the data as well.



We can begin with setting the Title to the center.The SSRS has a tool bar button to horizontally center align the Titles or anyother report item in the exact center of the page. The tool also  has thesimilar functionality for the vertical center alignment
of a report item.  



The following screenshots show the steps to formata number in the SSRS for applying the thousand separators to the numbers. Youmay also add the currency symbol to the Amount fields used in the reports.

Right click on the textbox of theNumber field you want to format and go to the textbox properties :



Click on the number and select theNumber in the category. Click the check box for the thousands :



To display the values in thecurrency format right click on the sale amount field 



Inthe text box properties click on the currency and check the thousand separatorbox. By default it will show the Dollar sign ($) but you can customize it tospecify the currency of your country by clicking on the symbol button.



Next we will do some conditional formatting to displaythe report rows in the alternate color for better visualizations. For thisclick on the details row on the tablix and right click and go to the properties(F4) and enter the following code in the background
color expression:

= IIF(RowNumber (Nothing) Mod 2 =
0,"LightGrey", "Transparent")




This will display the Tablix rows in the alternatecolors.  You may change the color scheme as per your requirement.

The sales amount total is being shown in the thousandsand therefore only few digits can been seen as the values have been formattedto thousands.



· Now to format the date to bedisplayed in the Indian format. Right click on the date textbox and go toexpressions and add the following expressions to format the date:



Preview the report  to see the output which will be asfollows:



More details on the date formatting can be found onthe msdn documentation. You can find it

here.

Alternatively, the conditional formatting can also be achieved byusing the switch statement as follows:

Click on the Sales Amount andpress F4.



Go to the color and specify thefollowing code in the expression





To make it look a bit more professional I will justadd  some fields, displaying the report run date and the report user who hasgenerated the report.

You can do this by adding the Global variables such asthe page numbers and the userId fields which are available as the built-infields when you click on the expressions. Also I have used the built inDateTime function Now to get today’s date and time.


 

Finally the report will look like the following whichhas been made pixel perfect for the printing as well.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql server 2008 r2 SSRS