Reports

For Report Generation JasperReports can be used. It is based on the itext library.

For PDF reports the PdfExporter can be used. As DataSource implementation is a FXBeanDataSource available.

As visual report editor you can use Jaspersoft Studio (Community Edition).

DataSource

FXBeanDataSource wraps Beans in FXBeans for building a rewindable JasperReports DataSource.

In the Templates (.jrxml) items can be accessed like maps.

PDFExporter

PDFExporter simplifies the export to PDF task. You need only a JasperReports File (compiled or uncompiled).

  • Report Parameter are optional by creation a Map of key/values.
  • DataSource is optional (use a FXBeanDataSource if needed)
  • optional exporter / report configuration

Example

// create report
val exporter = PdfExporter(Resource.getUrl("report/personTable.jrxml"))
val exportResult = exporter.exportReport(
  File.newTemporaryFile(),
  Map("text" -> "All Persons"),
  FXBeanDataSource.fromObservableList[Person](tableFilter.selectedItems)
)
// open report
if (exportResult.completed) {
  if (System.getProperty("os.name").contains("Mac"))
    "open %s".format(exportResult.exportFile.pathAsString) !
  else
    "xdg-open %s".format(exportResult.exportFile.pathAsString) !
}