-
Book Overview & Buying
-
Table Of Contents
JasperReports for Java Developers
So far we've seen all of the JRDataSource implementations provided by JasperReports. If we need to extract data from a type of datasource not directly supported by JasperReports, we can create a class implementing JRDataSource to meet our needs. In this section, we will create a CsvDataSource class, which will allow us to create reports from Comma Separated Value (CSV) files.
To aid us in CSV parsing, we will use Glen Smith's excellent OpenCsv library. OpenCsv contains utility classes to ease the task of working with CSV files. OpenCsv is licensed under the Apache 2.0 license. It can be downloaded from http://opencsv.sourceforge.net/.
As we have seen from previous examples, all JasperReports datasources implement the JRDataSource interface. JasperReports also includes the net.sf.jasperreports.engine.JRRewindableDataSource interface. This interface extends JRDatasource, adding a single method called moveFirst()....
Change the font size
Change margin width
Change background colour