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
The attributes required to be used with this type of data soruce are reflected in the following table:
| Attribute | Optional | Description |
| value | false | XLS Document which contains the data. |
Valid values for attribute value are:
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" />
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 java.io.*;
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;
}
@PreDestroy
public void release() {
if (xlsStream != null) {
try {
xlsStream.close();
} catch(IOException e) {
e.printStackTrace();
}
}
// 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}" />