Map datasources

JasperReports allows us to use instances of any class implementing the java.util.Map interface as a datasource. We can use either an array or a collection of Map objects to generate a report. Each Map in the collection or array is a record that will be used to generate the data for each row in the detail area of the report. The JasperReports API provides an implementation of net.sf.jasperreports.engine.JRDataSource called net.sf.jasperreports.engine.data.JRMapArrayDataSource that we can use for using an array of Map objects as a datasource. The following example demonstrates this class in action:

package net.ensode.jasperbook; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.