I need to create a report where the number of columns changes based on the data being passed to iReport just like with a subreport. Is there a way to do this?
I agree with Ischin's answer, but I will elaborate.
The Crosstab Report will allow you to have dynamic columns because it allows you to pivot your data. You can select one or more fields to group by to create the columns. The values of the groups become the labels for the columns and then you must use aggregate functions for the values in the report called Measures (e.g., sum or count). If you select more than one field, you will have multiple levels of columns. When you design the report, you pick the size of the columns--they must all have the same size.
JasperReports is a product designed for creating something that will print on a piece of paper consistently, like a PDF. iReport as of at least version 5.1.0, does not have any other way to truly dynamically create columns. You could write in logic to show or hide columns based on parameters, but this would be very tedious and does not fit in with what JasperReports is designed for. It would be very difficult, for example, to allow the user running the report to select parameters that allow the user to control which columns are in the report and the positions of the columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With