Here I will post problems I and my colleagues met and solutions we found.

Monday, November 16, 2009

ReportViewer control from Microsoft

Recently we needed to add reporting capabilities to our web site. We had following requirements

  • All standard requirements for report designs, they are pretty much the same everywhere.
  • Ability to share report designs between web and desktop applications.
  • Export to PDF and Excel.
  • Royalty free.

We decided to try Microsoft Report Viewer control from VS 2008. And we started with web. Also, we have our "Data Access layer" which produces data as lists of objects, no direct access to the database. There is some logic involved in building these data both in database and in .NET.

You can find what report viewer control can and cannot do anywhere, what surprised me is the way it's done.

First of all, we didn't use Reporting Service, we used LocalReport.

  1. LocalReport uses a lot of memory. To give you an idea, we used set of data with about 50,000 records. It took about 16Mb of memory for the data and then it took about 200Mb to prepare report in PDF. It was much worse for Excel, 500Mb. We tried to add/remove sorting from rdlc template - 100Mb difference. This was exporting reports without using ReportViewer control itself.
  2. Then we tried to use ReportViewer web control. The problem here was that it uses about same amount of memory from sessions. OK, it doesn't make much sense to prepare such reports in "on-demand" mode. Still it took about 20Mb for 3000 records. This is just terrible
  3. Not only control uses session, it leaves objects in session when rendering is done and we clear the list of data sources.
  4. Export to Excel is supported for Office 2003, not 2007
  5. Not an issue, but everything is copied in two namespaces, WinForms and Web. Why not to reuse LocalReport?

So, what we are going to do next? First of all we are going to try to use Reporting Services. I expect it to be little bit tricky since we still don't want to use direct access to the database, but use our Data Access layer, but it seams doable. When using Reporting Services ReportViewer control supposed to be able to work without using session.

Second, we will break batch reports into multiple files. Having grouping and sorting in mind, this two will require some additional efforts.

I will report how this is going.