org.springframework.ui.jasperreports
Class JasperReportsUtils

java.lang.Object
  extended by org.springframework.ui.jasperreports.JasperReportsUtils

public abstract class JasperReportsUtils
extends Object

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

Since:
1.1.3
Author:
Rob Harrop, Juergen Hoeller

Constructor Summary
JasperReportsUtils()
           
 
Method Summary
static net.sf.jasperreports.engine.JRDataSource convertReportData(Object value)
          Convert the given report data value to a JRDataSource.
static void render(net.sf.jasperreports.engine.JRAbstractExporter exporter, net.sf.jasperreports.engine.JasperPrint print, OutputStream outputStream)
          Deprecated. in favor of the render version with JRExporter parameter
static void render(net.sf.jasperreports.engine.JRAbstractExporter exporter, net.sf.jasperreports.engine.JasperPrint print, Writer writer)
          Deprecated. in favor of the render version with JRExporter parameter
static void render(net.sf.jasperreports.engine.JRExporter exporter, net.sf.jasperreports.engine.JasperPrint print, OutputStream outputStream)
          Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied OutputStream.
static void render(net.sf.jasperreports.engine.JRExporter exporter, net.sf.jasperreports.engine.JasperPrint print, Writer writer)
          Render the supplied JasperPrint instance using the supplied JRAbstractExporter instance and write the results to the supplied Writer.
static void renderAsCsv(net.sf.jasperreports.engine.JasperReport report, Map parameters, Object reportData, Writer writer)
          Render a report in CSV format using the supplied report data.
static void renderAsHtml(net.sf.jasperreports.engine.JasperReport report, Map parameters, Object reportData, Writer writer)
          Render a report in HTML format using the supplied report data.
static void renderAsPdf(net.sf.jasperreports.engine.JasperReport report, Map parameters, Object reportData, OutputStream stream)
          Render a report in PDF format using the supplied report data.
static void renderAsXls(net.sf.jasperreports.engine.JasperReport report, Map parameters, Object reportData, OutputStream stream)
          Render a report in PDF format using the supplied report data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JasperReportsUtils

public JasperReportsUtils()
Method Detail

convertReportData

public static net.sf.jasperreports.engine.JRDataSource convertReportData(Object value)
                                                                  throws IllegalArgumentException
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
Throws:
IllegalArgumentException - if the value could not be converted
See Also:
JRDataSource, JRBeanCollectionDataSource, JRBeanArrayDataSource

render

public static void render(net.sf.jasperreports.engine.JRAbstractExporter exporter,
                          net.sf.jasperreports.engine.JasperPrint print,
                          Writer writer)
                   throws net.sf.jasperreports.engine.JRException
Deprecated. in favor of the render version with JRExporter parameter

Throws:
net.sf.jasperreports.engine.JRException
See Also:
render(net.sf.jasperreports.engine.JRExporter, net.sf.jasperreports.engine.JasperPrint, java.io.Writer)

render

public static void render(net.sf.jasperreports.engine.JRExporter exporter,
                          net.sf.jasperreports.engine.JasperPrint print,
                          Writer writer)
                   throws net.sf.jasperreports.engine.JRException
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:
net.sf.jasperreports.engine.JRException - if rendering failed

render

public static void render(net.sf.jasperreports.engine.JRAbstractExporter exporter,
                          net.sf.jasperreports.engine.JasperPrint print,
                          OutputStream outputStream)
                   throws net.sf.jasperreports.engine.JRException
Deprecated. in favor of the render version with JRExporter parameter

Throws:
net.sf.jasperreports.engine.JRException
See Also:
render(net.sf.jasperreports.engine.JRExporter, net.sf.jasperreports.engine.JasperPrint, java.io.OutputStream)

render

public static void render(net.sf.jasperreports.engine.JRExporter exporter,
                          net.sf.jasperreports.engine.JasperPrint print,
                          OutputStream outputStream)
                   throws net.sf.jasperreports.engine.JRException
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:
net.sf.jasperreports.engine.JRException - if rendering failed

renderAsCsv

public static void renderAsCsv(net.sf.jasperreports.engine.JasperReport report,
                               Map parameters,
                               Object reportData,
                               Writer writer)
                        throws net.sf.jasperreports.engine.JRException
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
writer - the Writer to write the rendered report to
reportData - a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
Throws:
net.sf.jasperreports.engine.JRException - if rendering failed
See Also:
convertReportData(java.lang.Object)

renderAsHtml

public static void renderAsHtml(net.sf.jasperreports.engine.JasperReport report,
                                Map parameters,
                                Object reportData,
                                Writer writer)
                         throws net.sf.jasperreports.engine.JRException
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
writer - the Writer to write the rendered report to
reportData - a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
Throws:
net.sf.jasperreports.engine.JRException - if rendering failed
See Also:
convertReportData(java.lang.Object)

renderAsPdf

public static void renderAsPdf(net.sf.jasperreports.engine.JasperReport report,
                               Map parameters,
                               Object reportData,
                               OutputStream stream)
                        throws net.sf.jasperreports.engine.JRException
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
stream - the OutputStream to write the rendered report to
reportData - a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
Throws:
net.sf.jasperreports.engine.JRException - if rendering failed
See Also:
convertReportData(java.lang.Object)

renderAsXls

public static void renderAsXls(net.sf.jasperreports.engine.JasperReport report,
                               Map parameters,
                               Object reportData,
                               OutputStream stream)
                        throws net.sf.jasperreports.engine.JRException
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
stream - the OutputStream to write the rendered report to
reportData - a JRDataSource, java.util.Collection or object array (converted accordingly), representing the report data to read fields from
Throws:
net.sf.jasperreports.engine.JRException - if rendering failed
See Also:
convertReportData(java.lang.Object)


Copyright (c) 2002-2007 The Spring Framework Project.