Wednesday, January 13, 2010

Export to excel from SQL report showing cached data

I have recently encountered a problem in SSRS report. I was basically trying to export to excel from my report. First time I rendered report for a set of parameters and export to excel it worked fine. But subsequent rendering with different parameters and exporting to excel was showing the earlier output itself. It was caching the initial copy and not picking up changed data.
I investigated and found out a quick tip which avoids this. The solution is to add the URL parameter &rs:ClearSession=true to report url which will clear session each time and render us latest data correctly. Hopefully this quick tip will help anybody who encounters the same problem in future.

Other similar URL parameters you can use in report url are

&rc:Parameters={Collapsed/true/false} - indicates if parameter bar is to be displayed or not and also whether value needs to be passed in browser
&rc:toolbar={true/false} - indicates if toolbar needs to be hidden or not
&rc:format={PDF/Excel,HTML} - renders report in specified format