Creating a static table in iReport

JDS picture JDS · Dec 10, 2010 · Viewed 15.2k times · Source

I've been playing with iReport (older version 3.0.0) for a while and I can't seem to find a way to make just a static table, which seems silly and leads me to think that I'm just dense. Can someone point me in the right direction? The goal is to generate a report with a table with 2 columns: segment # and segment name. For each report, there will always be 20 segments, so the end report would look something like the following:

| 1 | <segment name> |
| 2 | <segment name> |
...
| 20 | <segment name> |

Thanks in advance for any help.

Answer

yshalbar picture yshalbar · Dec 13, 2010

The normal way to create a table in Jasper is to use text-boxes (I know, this is not so normal, but Jasper is just dense)

To understand Jasper, you need to understand how the bands work.
The Detail band is used for each row of your data.

In the Detail band you should create two Text Fields, one with $F{segment_id} and one with F${segment_name} (Assuming your query use those fields).
When you run the report, this will become your table body.

To add a header to your table, use the Column Header band. Add Static Texts with 'ID' and 'Segment Name' - this will appear as a table header on each page.

Note that you should keep the text-boxes close together, taking the whole band hight, so it will look like a table and not just floating text-boxes.

(Note - this is the classic way to create tables in Jasper, but the new Jasper versions also contain a Table element designed specifically for tables)