public abstract class

JasperReportsUtils

extends Object
java.lang.Object
   ↳ org.springframework.ui.jasperreports.JasperReportsUtils

Class Overview

Utility methods for working with JasperReports. Provides a set of convenience methods for generating reports in a CSV, HTML, PDF and XLS formats.

Summary

Public Constructors
JasperReportsUtils()
Public Methods
static JRDataSource convertReportData(Object value)
Convert the given report data value to a JRDataSource.
static void render(JRExporter exporter, JasperPrint print, Writer writer)
Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied Writer.
static void render(JRExporter exporter, JasperPrint print, OutputStream outputStream)
Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied OutputStream.
static void renderAsCsv(JasperReport report, Map parameters, Object reportData, Writer writer, Map exporterParameters)
Render a report in CSV format using the supplied report data.
static void renderAsCsv(JasperReport report, Map parameters, Object reportData, Writer writer)
Render a report in CSV format using the supplied report data.
static void renderAsHtml(JasperReport report, Map parameters, Object reportData, Writer writer, Map exporterParameters)
Render a report in HTML format using the supplied report data.
static void renderAsHtml(JasperReport report, Map parameters, Object reportData, Writer writer)
Render a report in HTML format using the supplied report data.
static void renderAsPdf(JasperReport report, Map parameters, Object reportData, OutputStream stream, Map exporterParameters)
Render a report in PDF format using the supplied report data.
static void renderAsPdf(JasperReport report, Map parameters, Object reportData, OutputStream stream)
Render a report in PDF format using the supplied report data.
static void renderAsXls(JasperReport report, Map parameters, Object reportData, OutputStream stream, Map exporterParameters)
Render a report in XLS format using the supplied report data.
static void renderAsXls(JasperReport report, Map parameters, Object reportData, OutputStream stream)
Render a report in XLS format using the supplied report data.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public JasperReportsUtils ()

Public Methods

public static JRDataSource convertReportData (Object value)

Convert the given report data value to a JRDataSource.

In the default implementation, a JRDataSource, java.util.Collection or object array is detected. The latter are converted to JRBeanCollectionDataSource or JRBeanArrayDataSource, respectively.

Parameters
value the report data value to convert
Returns
  • the JRDataSource (never null)
Throws
IllegalArgumentException if the value could not be converted
See Also
  • net.sf.jasperreports.engine.JRDataSource
  • net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
  • net.sf.jasperreports.engine.data.JRBeanArrayDataSource

public static void render (JRExporter exporter, JasperPrint print, Writer writer)

Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied Writer.

Make sure that the JRAbstractExporter implementation you supply is capable of writing to a Writer.

Parameters
exporter the JRAbstractExporter to use to render the report
print the JasperPrint instance to render
writer the Writer to write the result to
Throws
if rendering failed
JRException

public static void render (JRExporter exporter, JasperPrint print, OutputStream outputStream)

Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied OutputStream.

Make sure that the JRAbstractExporter implementation you supply is capable of writing to a OutputStream.

Parameters
exporter the JRAbstractExporter to use to render the report
print the JasperPrint instance to render
outputStream the OutputStream to write the result to
Throws
if rendering failed
JRException

public static void renderAsCsv (JasperReport report, Map parameters, Object reportData, Writer writer, Map exporterParameters)

Render a report in CSV format using the supplied report data. Writes the results to the supplied Writer.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
writer the Writer to write the rendered report to
exporterParameters a Map of JRExporterParameter exporter parameters
Throws
if rendering failed
JRException

public static void renderAsCsv (JasperReport report, Map parameters, Object reportData, Writer writer)

Render a report in CSV format using the supplied report data. Writes the results to the supplied Writer.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
writer the Writer to write the rendered report to
Throws
if rendering failed
JRException

public static void renderAsHtml (JasperReport report, Map parameters, Object reportData, Writer writer, Map exporterParameters)

Render a report in HTML format using the supplied report data. Writes the results to the supplied Writer.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
writer the Writer to write the rendered report to
exporterParameters a Map of JRExporterParameter exporter parameters
Throws
if rendering failed
JRException

public static void renderAsHtml (JasperReport report, Map parameters, Object reportData, Writer writer)

Render a report in HTML format using the supplied report data. Writes the results to the supplied Writer.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
writer the Writer to write the rendered report to
Throws
if rendering failed
JRException

public static void renderAsPdf (JasperReport report, Map parameters, Object reportData, OutputStream stream, Map exporterParameters)

Render a report in PDF format using the supplied report data. Writes the results to the supplied OutputStream.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
stream the OutputStream to write the rendered report to
exporterParameters a Map of JRExporterParameter exporter parameters
Throws
if rendering failed
JRException

public static void renderAsPdf (JasperReport report, Map parameters, Object reportData, OutputStream stream)

Render a report in PDF format using the supplied report data. Writes the results to the supplied OutputStream.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
stream the OutputStream to write the rendered report to
Throws
if rendering failed
JRException

public static void renderAsXls (JasperReport report, Map parameters, Object reportData, OutputStream stream, Map exporterParameters)

Render a report in XLS format using the supplied report data. Writes the results to the supplied OutputStream.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
stream the OutputStream to write the rendered report to
exporterParameters a Map of JRExporterParameter exporter parameters
Throws
if rendering failed
JRException

public static void renderAsXls (JasperReport report, Map parameters, Object reportData, OutputStream stream)

Render a report in XLS format using the supplied report data. Writes the results to the supplied OutputStream.

Parameters
report the JasperReport instance to render
parameters the parameters to use for rendering
reportData a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
stream the OutputStream to write the rendered report to
Throws
if rendering failed
JRException