Friday, October 26, 2012

SSRS- How to add Image in the report


1.     Background

This article describes how to add Images in the report. Many times, Report needs some special symbols or images to indicate special attributes in the report. It will make report more interactive and simplified the report for the business users.

2.     What is Image Report Item?

An image is a report item that contains a reference to an image that can be available in below places:
·         It can be embedded in the report,
·         It can be stored in a database
·         It can be stored on the report server
·         It can be stored in any Web.
An image can be a picture that is repeated with rows of data. You can also use an image as a background for certain report items. Storing logos on a server is a good idea because you can use the same logo in many reports.

3.     Steps to add the Image in the report by embedding it in the report:

Below is the simple Employee report in which we will add Images for gender attribute:

                       I.     Here we will add the Image report item for gender column. For adding images, go to the Report Data pane, right click on the Images and click on Add Image.

Give the path for the image and click ok.
Repeat the same step for Male.png

                     II.       To verify whether images are embedded in the report definition or not, go to the Report Data pane, expand Image folder and see whether images are available or not:

Here we have embedded images successfully.

                   III.     To add Image report item on gender column, right click on the Gender column then Insert and Select Image


It will open the Image property window. Select the image source as Embedded:


                   IV.       Here we will use the expression for showing male and female images to respective gender. Click on the expression button and write the below expression and click ok:

=SWITCH(Fields!Gender.Value= "Male","Male",Fields!Gender.Value= "Female","Female")

                     V.            See the report layout; we can see the image item in the gender column.
                   VI.            Preview the report and see whether we are getting images for gender or not:
Report is showing the images correctly.

4.     Steps to add image in the report which is stored in the report server

                       I.            Below is the current location of the images in the report server:
                     II.       To add Image report item on gender column, right click on the Gender column then Insert and Select Image

It will open the Image property window. Select the image source as External:

                   III.      We will use the expression to show the images with respect to gender. For writing expression, click on expression builder button and type the below expression:

=SWITCH(Fields!Gender.Value = "Male", "http://vishal-pc/reportserver?%2fImages%2fMale.png&rs:Command=GetResourceContents",

Fields!Gender.Value= "Female","http://vishal-pc/reportserver?%2fImages%2fFemale.png&rs:Command=GetResourceContents")

Click Ok.
                   IV.            See the report layout. Gender column should show image item:

                     V.            Preview the report:
So Report is showing the images correctly .

5.     Conclusion

By using the above steps, we can implement Image report item in the report to make report more interactive that is very helpful for users to analyse the data easily.

----------------------------------------------------End of Document--------------------------------------------------

No comments:

Post a Comment