Random Ramblings

Archive for September, 2008

Custom Reports in .NET?

by admin on Sep.01, 2008, under Programming

When I wrote my first incarnation of the student database back in January 2005, we needed some reports (receipts, student lists etc).  I used part of the ComponentOne Studio for .NET that I was lucky enough to acquire as part of the free VB.NET Resource Kit.  It worked well, but the report requirements for that application were fairly small.

For our main office application, the requirements were much higher.  We’re a franchise of a national organisation and so twice a month need to provide the major franchise with reports on the number of clients served and the amount of money received.  Given that we have a large number of locations to report on, the report generally spans a few pages.

I had learnt about the Crystal Reports for Visual Studio .NET and how to use them after developing and deploying the student database, and as such wanted to use that package rather than ComponentOne, as the report I needed to do is something like Crystal’s Cross-Tab report.  The ComponentOne reporting component was rather primitive in this regard.

I did try the Crystal Cross-Tab, and although it almost worked for a small number of locations, the large number we have meant that it would fail to display correctly.

In the end, after some research, I found that I could extend the System.Drawing.Printing.PrintDocument class, override the OnPrintPage event and manually generate the table structure and output the data required, in the format I wanted.  It is a rather crude solution, but it works.

I have extended it in the past few months, because I wanted to be able to generate a PDF output with a particular filename, as the report viewer I was using wouldn’t allow me to do that without displaying a save dialog.  After searching for .NET PDF components, I eventually found one which did everything I wanted called iTextSharp (http://itextsharp.sourceforge.net/).  Again, the work I had to do behind the scenes to translate the calls to e.Graphics into outputs onto the PDF is crude, but it works well.

I bring this up after all this time, because I’m about to create my first new report using this format in the last few years for the rostering application.  I just hope I can remember how to do it.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended friends...