1. Presentation
2.Basic concepts
3.Input
From File
From DB
Custom input
4.Output
HTML
Excel
Custom
5.Flat reports
Simple
Aggregated
6.Cross tab reports
Simple
Aggregated


3. The input

The input represents the basic data from which you want to obtain the report.
Usually the input data comes from a file or from a database query, or at least, these are the cases covered in this release, but there's no restriction in writing your own implementation for the report input as long as you implement net.sf.reportengine.IReportInput interface

  • net.sf.reportengine.in.FileDataProvider - this class should be used when the input data resides on a file
  • net.sf.reportengine.in.QueryDataProvider - use this when your data resides on a database table of view

3.1 File input

This is one ReportInput implementation which assumes that one file contains the data for your report. How can I construct a File Provider ...very easy:
ReportInput input = new FileDataProvider("./input.txt"));

3.2 Database input

This is probably the most important data provider (or ReportInput) and the most used . In order to construct such a provider you need a database connection:

Connection dbConnection = .... // construct your connection as you wish
QueryDataProvider queryInput = new QueryDataProvider(dbConnection);
queryInput.setSqlStatement("select * from table ");


But the provider can also construct its own connection having the needed data : user, password, connectionString, driver class
QueryDataProvider queryInput = new QueryDataProvider();
queryInput.setDbConnString("jdbc:oracle:thin:@localhost:1521:testdb");
queryInput.setDbDriverClass("oracle.jdbc.OracleDriver");
queryInput.setDbUser("scott");
queryInput.setDbPassword("tiger");
queryInput.setSqlStatement(
    "select t.country, t.region, t.city, t.sex, t.religion, t.count "+
    "from testreport t "+
    "order by t.country, t.region, t.city, t.sex, t.religion");

3.3 Custom input

To be completed soon !

Support This Project java.net community ©dragos balan