tags:

views:

570

answers:

5

I want to print, email and write to PDF very simple reports. The reports are basically a list of items, divided in various sections/columns. The sections are not necessarily identical. Think newspaper.

I just wasted a solid 2 days of work trying to make this kind of reports using JasperReports. I find that Jasper is great for outputing "normalized" data. The kind that would come out of a database for instance, each row neatly describing an item and each item printed on a line. I'm simplifying a bit but that's the idea.

However, given what I want to do I always ended up completely lost. Data not being displayed for no apparent reason, columns of texts never the correct size, column positioning always ending up incorrect, pagination not sanely possible (I was never able to figure it out; the FAQ gives an obscure workaround), etc.

I came to the conclusion that Jasper is really not built to make the kind of reports I want. Am I missing something?

I'm ready to pay for a tool, as long as the price is reasonable. By reasonable I mean a few $100s.

Thanks.

EDIT: To answer cetus, here is more information about the report I made in Jasper.

What I want is something like this:

text        text
text        text
-------------------
text    |   text
text    |----------
text    |   text
text    |   text
--------|   text
text    |----------
text    |   text

What I made in jasper is this:

(detail band)
subreport       |      subreport
------------------------------------
subreport       |      subreport
------------------------------------
subreport       |      subreport

The subreports are all the same actual report. This report has one field (called "field") and basically just prints this field in a detail band. Hence, running a single subreport simply lists all items from the datasource. The datasource itself is a simple custom JRDatasource containing a collection of strings in the field "field". The datasource iterates over the collection until there are no more strings. Each subreport has its own datasource.

I tried many different variations of the above, with all sorts of different properties for the report, subreports, etc.

IMO, this is fairly simple stuff. However, the problems I encounter are as follows:

  • Subreports starting from the 3rd don't show up when their position type is 'float'. They do show up when they have 'fix relative to top'. However, I don't want to do this because the first two subreports can be of any length.
  • I can't make each subreport to stretch according to its own length. Instead, they either don't stretch at all (which is not desirable because they have different lenghts) or they stretch according to the longest subreport. This makes a weird layout for sure.
  • Pagination doesn't happen. If some subreports fall outside the page, they simple don't show. One alternative is to increase the 'page height' considerably and the 'detail band height' accordingly. However, in this case it is not really possibly to know the total height in advance. So I'm stuck with calculating/guessing it myself, before the report is even generated. More importantly, long reports end up on one page and this is not acceptable (the printout text is too small, it's ugly/non-professional to have different reports with different PDF page lengths, etc.).

BTW, I used iReport so it's possibly limitations of iReport I'm listing here and not of Jasper itself. That's one of the things I'm trying to find out asking this question here. One alternative would be to generate the jrxml myself with just static text but I'm afraid I'll encounter the very same limitations. Anyway, I just generally wasted so much time getting anything done with Jasper that I can't help thinking its not the right tool for the job. (Not to say that Jasper doesn't excel in what it's good at).

+2  A: 

Take a look at the iText library. You can write pdf documents in pure Java. And it is open source.

Kees de Kooter
+1  A: 

Jasper is as good or bad as you use it. If you have 5 columns you can represnet one row like this:

one two three four five

or like this:

one
two
three
four
five

However you like really. But yes you have to phrase your report in the right sort of normalized views. Jasper, as a classic reporting tool, works on two dimensional data but within that each row can be represented however you like and data spanning multiple rows can be grouped (and grouped within groups).

I don't really know what the report you want to generate is or what you data is--your description doesn't really give me a clear picture--so it's hard to say one way or the otehr whether Jasper (or something else) is right for you or not.

cletus
A: 

My approach of that kind of problem would probably seem completely crazy to most of you here... but here is what I would do:

  • write some Java code that builds a proper LaTeX document for my report
  • invoke (through exec) latex to compile it
  • invoke dvipdf to make it into a pdf

If you know LaTeX it would probably take, oh, a couple of hours to work, and then if you want to generate plain text, ps, raster, or whatever version of your doc dvi has a converter for (and they are plenty), you have it in about 30 seconds. Plus, you have the LaTeX source that can be edited by hand or included if need be.

Varkhan
+1  A: 

i-net Crystal-Clear has a multicolumn feature. You can setup how many columns you want and if grouping is part of the multicolumn. You can create a report like a news paper.

Horcrux7
A: 

Late, but possibly of general interest for readers of this posted question. Docmosis uses odt and doc files as templates and has a Java API for manipulating and populating the template. This means you can layout your template in column format and that format will be retained for the output document. This becomes a template-layout control rather than a code-control which is a much nicer way of achieving the layout changes. Docmosis relies on Java and OpenOffice to do its magic.

To see if it would Docmosis could produce a desirable result without having to trial an integration, install create a document that looks like you'd want (aka an example multi-column document) as a doc or odt file. Install OpenOffice and load it in. Then save it as a PDF or doc or odt. View the result, if it preserves all the content and layout you'd expect, then Docmosis could be used to automate this and populate from Java.

jowierun