If you are upset about the huge
amount of memory and processor time the traditional report libraries use,
or if you are upset with the several
you'll-never-need
dependencies added by them, or if you dislike the
edit-on-the-code-than-edit-the-template-at-the-design-application-than-compile-both-and-finally-try-if-fixes
dance every time you need to fix a little bug in your reports, or even if
you just want a simple and efficient way to generate reports, then
![NervalReports](img/nerval.png)
is just for you!
reportGenerator.beginPageHeaderCenter();
reportGenerator.addText("I'm a report page header");
reportGenerator.addSeparatorLine();
reportGenerator.endPageHeaderCenter();
Code 1: A page header definition in Nerval Reports
Nerval Reports is a lightweight report creation library,
focused on minimal computational costs. Instead of the highly expensive way of
well-known engines like Jasper Reports, where performance and data reiteration
is a big and set aside problem (and also is the report design as a
non-programming task), at Nerval Reports the data should be sent directly when
iterating through it and the design is mainly focused on the programmer's side.
For example, when using relational databases, one will create its report while
iterating through the result set - instead of creating a bunch of collections
to pass them to the library:
reportGenerator.beginTable(2);
/* Generate table header */
reportGenerator.beginTableHeader();
reportGenerator.beginTableHeaderRow();
reportGenerator.addTableHeaderCell("Name");
reportGenerator.addTableHeaderCell("City");
reportGenerator.endTableHeaderRow();
reportGenerator.endTableHeader();
/* Generate table rows. */
try {
resultSet = doDatabaseSelect();
while (result.next()) {
reportGenerator.beginTableRow();
reportGenerator.addTableCell(resultSet.getString(NAME));
reportGenerator.addTableCell(resultSet.getString(CITY));
reportGenerator.endTableRow();
}
} finally {
if (resultSet != null) {
resultSet.close();
}
}
/* Done */
reportGenerator.endTable();
Code 2: A table creation direct from the ResultSet
Each project should include just the generators it needs (and the report code
is generic enough to work on all generators with little to no changes), keeping
your project dependencies only to what it really needs (Why other libraries
requires some pdf libraries when you just want to generate a CSV file? Or why
to include HTML support when you just need a direct PDF creation?).
<dependency>
<groupId>net.sf.nervalreports</groupId>
<artifactId>pdf-generator</artifactId>
<version>1.1.1</version>
</dependency>
Code 3: Maven dependency for Nerval Reports PDF generator
Try some
examples or read our
docs for more information, and start using NervalReports at your projects now!