Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a static table in iReport

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.

like image 982
JDS Avatar asked Dec 10 '10 21:12

JDS


People also ask

How do I create a dataset in Jasper report?

Creating a DatasetRight-click the report root node in the outline view and choose Create Dataset: 2. In the Dataset wizard, name your dataset, choose Create new dataset from a connection or Data Source and click Next. The Dataset - Data Source window opens.


1 Answers

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)

like image 68
yshalbar Avatar answered Sep 16 '22 20:09

yshalbar