resize crosstab width depending on the number of columns


I want my crosstab always try to fill the page width regardless of the number of columns and I have no idea  how I can do this.

For example, I have a crosstab that at page 1 contains 4 columns, and at page 2 it contains 2 columns because of data. I programmatically resize the column width before filling the report. The problem is that if I calculate the column width for the max number of columns in report (4 columns), the crosstabs that contain fewer columns (for example 2 columns at page 2) won't have the same size.

Is there any way or property so I can do this? How can I set the column width foreach crosstab depending the number of columns?



daniherculano84's picture
Joined: Jul 10 2013 - 2:16am
Last seen: 10 years 2 months ago

1 Answer:

See the ignoreWidth attribute at



lucianc's picture
Joined: Jul 17 2006 - 1:10am
Last seen: 10 hours 56 min ago

My application is using jasperreports-3.1.4.jar and this attribute can not be used although I design jrxml with iReport 5.1.0. From what Jasper version can I use ignoreWidth attribute?

daniherculano84 - 10 years 2 months ago

The attribute was introduced in 3.5.3.

lucianc - 10 years 2 months ago

OK. Now I can use it but my crosstab doesn't expand to page width when the crosstab is smaller than page width. I just observed that a crosstab bigger than page width will exceed the page width if the attribute is true and I don't want this. Why the crosstab doesn't expand its columns?

daniherculano84 - 10 years 2 months ago
show 2 more...

My bad, I haven't read your question properly, ignoreWidth won't help.

There is no builtin feature to stretch crosstab column widths to fill the entire page.

You might still be able to do something programmatically in the lines of your existing solution, but it won't be pretty. You could have the crosstab in a subreport, and prior to each subreport/crosstab occurrence compute the number of columns and dynamically alter the crosstab element in the subreport. You would use something like MyCrosstabCustomizer.getReport("crosstabSubreport.jrxml", 4) as subreport expression.

lucianc - 10 years 2 months ago


Thanks for the solution. I faced same issue and trying to fix using this solution. But i found that this post is very old. Is there any support for stretch crosstab column width to fill the entire page in newer version? I upgraded jasper library to 6.3, let me know if latest version supports this.

rajil - 6 years 12 months ago