Up until now, we learned how to bootstrap our application using Activator, develop our web application using the Scala and Play framework, and a add reactive microservices call using RxScala for data flow computations. We also performed unit test and controller testing using the BDD and Play framework. Then, we persisted data into MySQL using Slick. Now we will move on with our application.
In this chapter, you will learn how to write reports with JasperReports. JasperReports is a very solid reporting solution for Java, and it can be used in Scala very easily. We will create database reports using Jasper, and change our application to have such functionality.
In this chapter, we will cover the following topics:
- • Understanding JasperReports
- • Adding database reports to our application
JasperReports (http://community.jaspersoft.com/project/jasperreports-library) is a very popular and solid reports solution that can generate reports in several formats, such as:
- • HTML
- • Excel
- • Word
- • Open Office format
In order to get your reports, you have a visual tool called Jaspersoft Studio, in which you can drag and drop elements such as labels, images, data fields, and much more. Jasper will store this metadata (the report definition) in an XML file, also known as JRXML. If you want, you can edit and work with this XML without any editor; however, it is way better to use the Jaspersoft Studio tool to gain productivity.
Jasper can work with several data sources, such as databases, XML, or even objects in memory. For this book, we will use the database datasource to access our MySQL database.