Ehsan Khodarahmi
Ehsan Khodarahmi

Reputation: 4922

How can I specify number of rows in detail band?

I've two problems :

1 - I want to specify number of rows which must be shown in every page of my report.

2 - If the number of fetched rows from datasource is less than amount required to fill page height, I want to fill remaining space with blank rows (every row is distinguished using its field borders). For example, if 50 rows can displayed in every page & there are only 20 rows of data which fetched from datasource, then I want to print 30 empty rows after last printed row. Consider that I cant do this with changing my sql select statement.

Can anybody help me please ?

Upvotes: 1

Views: 6665

Answers (3)

Charly
Charly

Reputation: 21

I had a similar problem, and here is a how I solved this.

First, you need a parameter (or variable maybe) with the total number of rows, and you will need the included variable Group_COUNT, "Group" will change reflecting the name of your group.

I had a parameter named "IDS", a List<Integer> used in the query to obtain the data, $P{IDS}.size() gives me the number of rows. I think you can also use the included variable "REPORT_COUNT".

Then, the most annoying part, you NEED to make the detail band long enough to hold all your data (in my case, 8 rows), and insert an image (or text component) in each row. This component will need to have 2 properties set, "Remove Line When Blank" and "Print When Expression", the first in true, and the second with the following condition:

new Boolean($P{IDS}.size() < 2 && $P{IDS}.size() == $V{Group_COUNT}.intValue())

You will have to replace $P{IDS}.size() with the expression reflecting your query row count, and the 2 with the row number, asuming you have at least 1 row, you can skip #1. Start with 2, and add 1 for every row, in your case, up to 50! (sorry!)

Upvotes: 2

AlexPB
AlexPB

Reputation: 21

I had the same problem, my solution was obtain the 'empty' rows trought the sql (ORACLE in my case) the query looks like this:

Select first_field, second_field, etc..
from my_table WHERE my_condition=${parameter}
UNION ALL
SELECT NULL,NULL, etc..
FROM EXISTING_TABLE_WITH_ROWS WHERE ROWNUM < 40 - (SELECT COUNT(*) FROM my_table WHERE   my_condition = ${parameter})

This create the empty rows above, now. If you don't see any change, try to set one field or label with the property 'Remove Line When Blank' Hope this help

Upvotes: 2

jechaviz
jechaviz

Reputation: 551

I can help you with your second request:

  1. Add a TextField with this relative position

    • left:1 pixel
    • top:1 pixel
  2. Put inside "\n\n..." 50 times. That print 50 rows always.

  3. Change the size of your text

    • width: 1 pixels
    • height: 15 pixels
  4. Tick option: Strecht when overflow.

Greetings

Upvotes: 0

Related Questions