Log note :
changed:
-
This document is a draft about how to use Gazpacho technology to build a report designer. It also gives some ideas about how to write a library to create printable output from this reports.

Template systems

  A template system allow the programmer to design templates that, when combined with meaningful data, will produce output data in one or more formats. A template is designed in such a way that it has placeholders where the data will be put into. Usually the template system offers a language to fill this placeholders with real data. The language should be easy enough so you don't need to be a programmer to write templates. It also should be powerful enough so complex data flows can be expressed inside the template but it should discourage the implementation of processing data algorithms that should be in the real programm instead.

  Examples of template systems are:

- <a href="http://smarty.php.net">Smarty</a>, for PHP based applications

- <a href="http://jakarta.apache.org/velocity/">Velocity</a>, for Java based applications

- <a href="http://www.zope.org">ZPT</a> (Zope Template Pages), for Zope applications

So we can use Gazpacho to design such templates and then, write a library that converts this template definitions into final reports, probably using the data from a database storage. Having this idea, these are the core components of the architecture:

Gazpacho -> Template files + Data -> Template Engine -> Intermediate output -> Output backends (PDF, HTML, RTF, ...)

The first thing we have to do is understand the requirements of a business report since this is the use case we are aiming at. Only after this analysis is done we could write a template system useful for our needs.

Reports requirement

  Usually there are two types of reports that a business will need to create:

- Financial reports to show to state of the company and/or analyze possible problems

- Nicely formated reports for documents that need to be exchanged with third parties like customers or providers

The requirements for these two kind of reports are not exactly the same since we want an easy and powerful way to create group of interrelated data output in the first case while we want high precision layout on the second case.

Usually financial reports are composed by:

- A main header in the first page with the title of the report and some general information

- A secondary header that appears in the second and all the other pages. This is useful to get a small information of the report so the user does not need to switch to the first page to remember what this report was about.

- A footer in all the pages with information as the number of the page or things like that

- A final footer in the last page with the computation results of the data in the report

- A body in all the pages. Usually a body is formed by columns representing some kind of query in the database. It's common the need to group the rows of the body by some grouping criteria having reports with hierarchycal structure. However is not usual to have more than 3 levels on this grouping tree.

- It should also be possible to insert graphics on this reports. Pie charts and bar charts are very useful to sumarize information from big sets of data.

With the other kind of reports, the ones that need good looking, the requirements are:

- Highly precised layout information. We need to be able to specify in a milimeter scale where every piece of data is going to appear.

- Relative and absolute layout. By mixing these two types of layout we can save a lot of time while designing a new report since we group the data attributes in containers and then we specify the position relative to these containers

- High resolution images for logos and product descriptions

- Paragraphs and other rich text layouts like lists or columns