cleverett has asked for the wisdom of the Perl Monks concerning the following question:

I'm on a module hunt. Looking for a module that will take one or more SQL queries and format the output in a flexible manner, using Perl formats, TT or HTML::Template, adding in headers, subheaders, subtotals and totals as specified. Think of it as Crystal Reports done in Perl without the WYSIWYG/GUI functionality. I've gone through CPAN, and can't find anything. But it could exist if someone didn't describe the project using the same language I just used. Any ideas?

Replies are listed 'Best First'.
Re: Report Generator
by dragonchild (Archbishop) on Jul 01, 2003 at 20:14 UTC
    There's a reason CrystalReports is ... less than ideal ... for most situations - it tries to do too much. Thus, it is extremely bloated and still doesn't do exactly what is desired.

    My recommendation is that you do the following:

    1. Use one of the SQL catalog modules to manage your queries. Of course, this assumes your queries are this static.
    2. Build the templates. TT and Mason are both very good for developing against multiple output formats. HTML::Template and PDF::Template also take the same data structure, which makes things nice.
    3. Hook them together and go.
    If you find a way to make this into a module or series of modules, post it!

    Now, another way to go could be this, if your problemspace decomposes nicely. I started this process at MasterCard.

    1. Build a series of objects, representing reports. Each report would contain all the SQL needed to pull its data together, as well as all the organizational needs to build the appropriate data structure(s).
    2. Build templates to match each report.
    I personally like that process because it allows for a lot of code reuse and decomposed my problemspace very neatly.

    Of course, as with everything, YMMDWV. (Your Mileage Most Definitely Will Vary.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      I want something like what they used to call a 'band report generator', ten years ago, where the output is formatted into horizontal bands. Crystal Reports probably does a whole lot more than that.

      This is actually the frst thing I've needed that I couldn't find a close fit for, so I'm writing my first CPAN module to do this. I'm going to call it DBIx::Band::Report or Data::Report::Formatter or something like that.

        I'm a little confused as to the problem here. Most templating systems have a looping construct. They also allow you to know whether you're in an odd or even row. Just vary the background depending on the row number's modulo 2. Or, would that not work?

        ------
        We are the carpenters and bricklayers of the Information Age.

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

(jeffa) Re: Report Generator
by jeffa (Bishop) on Jul 01, 2003 at 20:55 UTC
      I like that universal template. I think I can use is somewhere.
Re: Report Generator
by steves (Curate) on Jul 01, 2003 at 21:30 UTC

    Have you looked at the DBIx Formatter module on CPAN?

      This has some of what I'm looking for, but it doesn't seem to do subtotals and subheads AFAICT, and it only uses Perl formats.