I am using Jaspersoft Studio 6.3.1.final to design a report with a table among other elements.
The design looks like below. The table only has a Column Header and a Detail section.
Now the fields are printed vertically like this:
COLUMN_HEADER1 | COLUMN_HEADER2
col1Val1 | ...
col1Val2 | ...
col1Val3 | ...
But what I need is to display them horizontally like this:
COLUMN_HEADER1 | col1Val1 | col1Val2 | col1Val3
COLUMN_HEADER2 | ... | ... | ...
I searched the net and couldn't get any luck.
Is there a way to do that? I am stuck in here. Your help will be greatly appreciated!
Edit:
That's how I pass in the data to the report (using existing Java service to generate a JRBeanCollectionDataSource).
List<Map<String, Object>> aListOfMap = ...;
JRDataSource jrDataSource = new JRBeanCollectionDataSource(aListOfMap);
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("DataSource", jrDataSource);
JasperPrint jasperPrint = getObjectPdf("reports/report.jrxml", parameters, new JREmptyDataSource());
This kind of requirement either need to be achieved while data retrieval or using crosstab
component.
You can refer link working with crosstabs in Jasper Reports for crosstab sample design.
Also refer the link Working with Tables and CrossTabs in JasperReports to know how table and crosstab differ in their functionality.
If you want to achieve this in table
, then you have to apply pivoting
in your data retrieval process.