How can I pass an object to jasper report as parameter?
How can I pass an object to jasper report as parameter?
I want to send Employee obj开发者_如何学JAVAect parameter to jasper report. And set value to text field on report like:
P{employee.firstname}
P{employee.lastname}
P{employee.email}
How to create and set property for parameter variable in employee.jrxml?
How to call jasper API and set employee object to parameter?
Perhaps try using the Employee object as a JavaBean datasource?
To send an object as a parameter, you have to:
- Define the parameter name and the type of the object in the .jrxml file
- Send a Map with the parameter
HashMap parameters = new HashMap<>(); parameter.put("object", new Object());
- In the .jrxml file you can use the parameter as following:
<textFieldExpression><![CDATA[$P{object}.getValue()]]></textFieldExpression>
It works for me
精彩评论