Jump to content
Changes to the Jaspersoft community edition download ×

pass list of objects instead of SQL query


Recommended Posts

I have a list of Employee in my java application.

    List employee = new ArrayList();

Instead of passing the SQL query (select * from employee) to iReport, I want to pass my list.

    Map map = new HashMap();
    map.put("queryReport","select * from EMPLOYEE");
    JasperPrint jp = JasperFillManager.fillReport(input,map,connection);
    JRExporter exporter = new JRPdfExporter();
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, output);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);

It would be great if someone can help me with the code which I have to use.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

don't understand exactly what you're trying to do... if you want to pass an object collection to your report, you will have to design a bean class first, like:

then fill your list with the bean objects:

List employee = new ArrayList();

employee.add(new MyEmployeeBean(...constructor needed...)

finally create a bean datasource and pass it to the report, e.g.:

JasperPrint jp = JasperFillManager.fillReport(..., ..., new JRBeanArrayDataSource(employee));

have a look here:


Cheers, Thomas


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...