Usage of the XLS Source

When using this kind of source we can load the data from a resource resolvable through the built-in resource loading mechanism or by means of a backing bean which will offer the data to the data source component.

Note: To use this feature you will need to use JasperReports 3.7.x

Configuring the data source

The attributes required to be used with this type of data soruce are reflected in the following table:

valuefalseXLS Document which contains the data.

Valid values for attribute value are:

  • A file handle to a resource accessible by the server which is running the application.
  • An URL to a resource accessible through internet
  • java.lang.String: A path to any kind of resource. It will be loaded using the built-in resource loading mechanism.
  • A stream ready to be used to read the XLS data. In this case, application is responsible of closing the stream
  • jxl.Workbook: A pre-loaded or dynamically created XLS document.


Simple Usage

The most simple usage is based on the built-in resource loading mechanism implemented inside the plugin using following way:

<jr:source type="xls" value="classpath:META-INF/datasource/test.xls" />

Using a backing bean

First of all, we need to design a JSF Managed Bean which will build the XML document that will be used by the data source component.

import javax.annotation.PreDestroy;
import jxl.Workbook;
import ...;

public class XLSDataBean {

    private InputStream xlsStream = null;


    // Dynamically created XML document
    public Workbook getXlsDocument() {
        // Build an XLS Document

    public InputStream getXlsStream() {
        if (xlsStream == null) {
            // Instantiate an input stream from a xls source
        return xlsStream;

    public void release() {
        if (xlsStream != null) {
            try {
            } catch(IOException e) {

        // Release other resources



Then, this managed bean can be used inside the JSP file that will render the report or report link.

<jr:source type="xls" value="#{XLSDataBean.xlsDocument}" />
<jr:source type="xls" value="#{XLSDataBean.xlsStream}" />

Using Queries

Currently, using queries with XLS data sources is not supported.