Tuesday, December 7, 2010

Crystal Reports Viewer in Sharepoint

I have an issue Regarding Crystal Reports.
I have created sharepoint 2007 web application and deployed it to the server, whcih have some reports. All Reports are working fine on Production site, but the Navigation images in toolbar of Crystal Reports. I pasted aspnet_client folder to Sharepoint site directory as well as in root Directory too. but havn't got that images. then i made virtual directory and gave permissions, but still not getting images on toolbar.
it usually causes problem better to use webpart for crystal reporting available here

follwoing actions willl also help to show images if aboove both not work

Solution 1:

1. In your WebPart override Render method. Within this override extract output HTML and replace “CrystalImageHandler.aspx” with something like this “CrystalImageHandler.xxx”. Render new HTML.

2. In web.config replace CrystalImageHandler.aspx with CrystalImageHandler.xxx within tag.

Now all CR image requests will be processed by CrystalDecisions.Web.CrystalImageHandler. I think this solution is pretty self-explanatory. Let me know if you need the source code on how to alter output HTML within Render override.

Unfortunately, SP team still did not allow us to have any httpHander tags in the web.config, so they suggested to create a layout page called CrystalImageHandler.aspx (goes into _layouts directory), inherit that page from our own class and process image request programmatically. So, here is

Solution 2:

Within code behind of CrystalImageHandler.aspx page on Page_Load event place this code:

Dim hndlr As New CrystalDecisions.Web.CrystalImageHandler

You will still have to override Render method of your WebPart and replace CrystalImageHandler.aspx path with something that will look like this:

sNewHTML = Regex.Replace(sCurrentHTML, “/CrystalImageHandler.aspx”, “/_layouts/your_folder_within_layouts_directory/CrystalImageHandler.aspx”).

Now you need to delete httpHandler tag from web.config.
Rename the CrystalImageHandler.aspx file to a different extension, so the MOSS handler won’t pick it up. Offcourse you’ll have to alter the web.config to include a handler to the correct file.
Place a custom made CrystalImageHandler.aspx file in the TEMPLATE/LAYOUTS directory of the 12 hyve. Now write a regex which will replace all calls to the old imagehandler with a call to that file which will be in the _layouts directory of your web app.

No comments: