Skip to main content

Notifications

Dynamic fonts in SSRS reports

 Sometimes we need to set the Font style and size on the SSRS reports based on the user needs. This can be achieved using the dynamic expressions available in SSRS report properties. Below is a similar scenario with an example.

Let us take a simple report which print the two fields. One is warehouses and the other is location. Now the font size of the each field should be printed according to the user input. Below is the sample design and code for the scenario.


1. Create the controller, and services classes as required.

2. In the contract class add integer fields as parameters to get the font size as input from user as below.




3. Now in the SSRS report design select the properties of the textbox for which this font size needs to be applied.

4. Click on the Font tab and select the fx expression button for font size as below.


5. Now under category section click on the parameter. The list of parameters available in the report will be displayed. Select the parameter which we created for font size in the contract class.


6. Actual font size will be of string value. Ex, '10pt'. But since the parameter we specified is of integer type, if we use the parameter value directly then the font size wont be applied. It takes the default font size.

7. In order to convert it to string and use use it change the expression as in below image.



8. Now Save, build and deploy the report. The report should bring the fonts based on the user input.








This was originally posted here.

Comments

*This post is locked for comments