top of page

Group

Public·91 members
Henry King
Henry King

Discover the Power and Flexibility of Pentaho Reporting 3.5 for Java Developers


Pentaho Reporting 3.5 for Java Developers Free Pdf




If you are a Java developer who wants to create advanced reports that connect to practically any data source using open source technology, then you should check out Pentaho Reporting. And if you want to learn how to use it quickly and efficiently, then you should download the free pdf of the book Pentaho Reporting 3.5 for Java Developers by Will Gorman.




Pentaho Reporting 35 For Java Developers Free Pdf



This book shows you how to replace or build your enterprise reporting solution from scratch with Pentaho's Reporting Suite. Through detailed examples, it dives deeply into all aspects of Pentaho's reporting functionalities, providing you with the knowledge you need to master report creation.


In this article, we will give you an overview of what Pentaho Reporting is and what topics are covered in the book. We will also show you how to get the free pdf of the book and where to find more resources and support.


Pentaho Reporting Overview




Pentaho Reporting is a Java class library for generating reports. It provides flexible reporting and printing functionality using data from multiple sources and supports output to display devices, printers, PDF, Excel, XHTML, PlainText, XML and CSV files.


Some of the features and benefits of Pentaho Reporting are:



  • Rich authoring tools: You can use the graphical Report Designer tool or the XML-based Report Designer tool to create complex reports with ease.



  • Reporting server: You can deploy your reports on the Pentaho BI Server or any other J2EE application server and access them through a web browser or a web service.



  • Java API for building reports: You can use the Pentaho Reporting Engine's XML and Java APIs to create dynamic reports programmatically or embed them into your existing Java applications.



  • Extensibility: You can extend Pentaho Reporting with custom data sources, functions, elements, output formats, and styles.



  • A business friendly open source license: You can use Pentaho Reporting for free under the LGPL license or purchase a commercial license for additional support and services.



The architecture and components of Pentaho Reporting are:



Component


Description


LibBase


A library of common utility classes and interfaces.


LibDocBundle


A library for handling document bundles, which are collections of resources used by reports.


LibFonts


A library for font management and rendering.


LibFormat


A library for formatting numbers, dates, and messages.


LibFormula


A library for parsing and evaluating formulas in reports.


LibLoader


A library for loading resources from various sources, such as files, URLs, or classpaths.


LibRepository


A library for accessing repositories of reports and resources.


LibSerializer


A library for serializing and deserializing reports and resources.


LibXml


A library for XML processing and validation.


Report Engine Core


The core of the Pentaho Reporting Engine, which defines the report model, the data sources, the output targets, and the layout engine.


Report Engine ExtensionsThe extensions of the Pentaho Reporting Engine, which provide additional data sources, functions, elements, output formats, and styles.


The roadmap and future plans of Pentaho Reporting include:


Improving the performance and scalability of the reporting engine.Adding more features and enhancements to the Report Designer tool.Supporting more data sources, output formats, and chart types.Integrating with other Pentaho products and technologies, such as Pentaho Data Integration, Pentaho Metadata, Pentaho Analysis Services, and Pentaho Dashboards.


Pentaho Reporting Client and Enterprise Examples




In this section, we will show you how to set up Pentaho Reporting and its prerequisites. We will also show you how to build your first report using Report Designer. Then we will show you how to embed your report in a Swing application and in an enterprise web application.


How to set up Pentaho Reporting and its prerequisites




To use Pentaho Reporting, you need to have the following software installed on your system:


A Java Development Kit (JDK) version 1.5 or higher. You can download it from http://java.sun.com/javase/downloads/index.jsp.An Apache Ant version 1.7 or higher. You can download it from http://ant.apache.org/bindownload.cgi.An Apache Tomcat version 5.5 or higher. You can download it from http://tomcat.apache.org/download-55.cgi.


To download the free pdf of the book Pentaho Reporting 3.5 for Java Developers, you need to register at https://www.packtpub.com/free-ebooks/pentaho-reporting-35-java-developers/9781847193199. After registering, you will receive an email with a link to download the pdf file. The pdf file contains the full text of the book as well as the source code and data files for the examples.


How to build your first report using Report Designer




To build your first report using Report Designer, you need to follow these steps:


folder.Create a new report by selecting File New from the menu bar.Create and configure your data source by selecting Data Add Data Source from the menu bar. You can choose from various types of data sources, such as JDBC, XML, CSV, Hibernate, OLAP, and more. For this example, we will use a JDBC data source that connects to a sample database called sampledata.Create a query that defines the data to be used in the report by selecting Data Add Query from the menu bar. You can write your own SQL query or use the graphical query designer to drag and drop fields from the data source. For this example, we will use a simple query that selects all fields from a table called products.Design the report layout by dragging and dropping elements from the palette to the report structure. You can use various types of elements, such as labels, fields, images, charts, sub-reports, and more. For this example, we will use a simple layout that consists of a report title, column headings, details band, and report summary.Preview and save your report by selecting File Preview or File Save As from the menu bar. You can preview your report in different output formats, such as PDF, Excel, HTML, and more. You can save your report as an XML file or as a document bundle that contains all the resources used by the report.


Congratulations! You have just created your first report using Report Designer. Here is how it looks like in PDF format:



How to embed your report in a Swing application




To embed your report in a Swing application, you need to follow these steps:


Create a new Java project in your preferred IDE (Integrated Development Environment), such as Eclipse or NetBeans.Add the Pentaho Reporting libraries and dependencies to your project's classpath. You can find them in the /lib folder of the Pentaho Reporting distribution.Create a Java class that extends JFrame and implements ActionListener. This class will be the main window of your Swing application.In the constructor of your class, create a JButton that will trigger the report generation and add it to the content pane of your frame.In the actionPerformed method of your class, create a ClassicEngineBoot instance and call its getInstance().start() method to initialize the Pentaho Reporting Engine.Create a JDialog that will display the report preview and set its size and title.Create a JRException instance and call its createReport() method to load the report definition from an XML file or a document bundle. Pass the file name or URL as a parameter to this method.Create a JFreeReportPanel instance and pass the report object to its constructor. This panel will render the report using Swing components.Add the panel to the content pane of your dialog and set it visible.


You have just embedded your report in a Swing application. Here is how it looks like when you run it:



How to embed your report in an enterprise web application




To embed your report in an enterprise web application, you need to follow these steps:



  • Create a new web project in your preferred IDE or use an existing one.



  • Add the Pentaho Reporting libraries and dependencies to your project's classpath and web archive (WAR) file. You can find them in the /lib folder of the Pentaho Reporting distribution.



  • Create a Java class that extends HttpServlet and overrides its doGet method. This class will be the report servlet that handles the report requests and responses.



  • In the doGet method of your class, create a ClassicEngineBoot instance and call its getInstance().start() method to initialize the Pentaho Reporting Engine.



  • Create a JRException instance and call its createReport() method to load the report definition from an XML file or a document bundle. Pass the file name or URL as a parameter to this method.



  • Create a ReportProcessor instance and pass the report object and the output format to its constructor. The output format can be one of the supported formats, such as PDF, Excel, HTML, and more.



  • Call the processReport() method of the processor and pass the servlet's output stream as a parameter. This method will generate the report and write it to the output stream.



  • Create a web page that contains a form with a button that submits a request to the report servlet. Optionally, you can add some input fields or parameters to customize the report.



You have just embedded your report in an enterprise web application. Here is how it looks like when you access it from a web browser:



Pentaho Reporting Examples in the Real World




In this section, we will show you some examples of how to use Pentaho Reporting in real world scenarios. We will use a sample database called sampledata, which contains data for ElectroBarn, a fictional electronics store. We will create three reports: an inventory report, an end of the day cashier balances report, and an invoice report.


How to set up the example data source




To set up the example data source, you need to follow these steps:



  • Create a MySQL database called sampledata on your system or use an existing one.



  • Create three tables in the database: products, sales, and customers. You can use the following SQL statements to create them:




CREATE TABLE products ( product_id INT PRIMARY KEY, product_name VARCHAR(50), product_description VARCHAR(200), product_price DECIMAL(10,2), product_stock INT, product_category VARCHAR(20) ); CREATE TABLE sales ( sale_id INT PRIMARY KEY, sale_date DATE, sale_time TIME, sale_amount DECIMAL(10,2), sale_cashier VARCHAR(20), sale_customer INT, sale_product INT, FOREIGN KEY (sale_customer) REFERENCES customers(customer_id), FOREIGN KEY (sale_product) REFERENCES products(product_id) ); CREATE TABLE customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(50), customer_address VARCHAR(100), customer_phone VARCHAR(20), customer_email VARCHAR(50) );



  • Populate the tables with some sample data. You can use any data you want or use the data files provided in the book's source code.



  • Add the MySQL JDBC driver to your project's classpath and web archive (WAR) file. You can download it from https://dev.mysql.com/downloads/connector/j/.



  • Create a JDBC data source in Report Designer that connects to the sampledata database. You can use the following connection settings:




Name


Value


Data Source Name


Sample Data Source


Data Source Type


JDBC Database Connection


JDBC Driver Class Name


com.mysql.jdbc.Driver


JDBC Connection URL


p;cacheCallableStmts=true&cacheResultSetMetadata=true&cacheServerConfiguration=true&elideSetAutoCommits=true&maintainTimeStats=false


Username


Your MySQL username


Password


Your MySQL password


You have just set up the example data source for ElectroBarn. You can now use it to create various reports.


How to create an inventory report with groupings, summaries, and a pie chart




To create an inventory report with groupings, summaries, and a pie chart, you need to follow these steps:



  • Create a new report in Report Designer and select the Sample Data Source as the data source.



  • Create a query that selects all fields from the products table and orders them by product_category and product_name.



  • Design the report layout as follows:




  • Add a label with the text "ElectroBarn Inventory Report" to the Report Header band and set its font size to 18.



  • Add a label with the text "Product Category" to the Group Header band and set its font size to 14.



  • Add a field with the value =PRODUCT_CATEGORY to the Group Header band next to the label and set its font size to 14.



  • Add labels with the texts "Product ID", "Product Name", "Product Description", "Product Price", and "Product Stock" to the Details Header band and set their font sizes to 12.



  • Add fields with the values =PRODUCT_ID, =PRODUCT_NAME, =PRODUCT_DESCRIPTION, =PRODUCT_PRICE, and =PRODUCT_STOCK to the Details band below the corresponding labels and set their font sizes to 10.



  • Add a label with the text "Total Products" to the Group Footer band and set its font size to 12.



  • Add a field with the value =COUNT([PRODUCT_ID]) to the Group Footer band next to the label and set its font size to 12. This field will show the number of products in each category.



  • Add a label with the text "Grand Total" to the Report Footer band and set its font size to 14.



  • Add a field with the value =COUNT([PRODUCT_ID]) to the Report Footer band next to the label and set its font size to 14. This field will show the total number of products in all categories.



  • Add a chart element to the Report Footer band below the field and set its type to Pie Chart. Set its data source type to Table Data Source and select the query that you created earlier. Set its category column expression to =PRODUCT_CATEGORY and its value column expression to =COUNT([PRODUCT_ID]). This chart will show the distribution of products by category.




  • Preview and save your report. You can choose any output format you want, but for this example we will use PDF.



You have just created an inventory report with groupings, summaries, and a pie chart. Here is how it looks like in PDF format:



How to create an end of the day cashier balances report with input parameters and subtotals




To create an end of the day cashier balances report with input parameters and subtotals, you need to follow these steps:



  • Create a new report in Report Designer and select the Sample Data Source as the data source.



the menu bar. You can name the parameter sale_date and set its type to Date.


  • Create a query that selects all fields from the sales table and filters them by the sale_date parameter. You can use the following SQL statement for the query:




SELECT * FROM sales WHERE sale_date = $sale_date



  • Design the report layout as follows:




  • Add a label with the text "ElectroBarn End of Day Cashier Balances Report" to the Report Header band and set its font size to 18.



  • Add a label with the text "Date:" to the Report Header band below the previous label and set its font size to 14.



  • Add a field with the value =SALE_DATE to the Report Header band next to the label and set its font size to 14. This field will show the date entered by the user.



  • Add a label with the text "Sale ID" to the Details Header band and set its font size to 12.



  • Add a field with the value =SALE_ID to the Details band below the label and set its font size to 10.



  • Add labels with the texts "Sale Time", "Sale Amount", "Sale Cashier", "Sale Customer", and "Sale Product" to the Details Header band next to the previous label and set their font sizes to 12.



  • Add fields with the values =SALE_TIME, =SALE_AMOUNT, =SALE_CASHIER, =SALE_CUSTOMER, and =SALE_PRODUCT to the Details band below the corresponding labels and set their font sizes to 10.



  • Add a group that groups the data by sale_cashier. You can do this by selecting Data Add Group from the menu bar and choosing sale_cashier as the group field.



  • Add a label with the text "Cashier:" to the Group Header band and set its font size to 14.



  • Add a field with the value =SALE_CASHIER to the Group Header band next to the label and set its font size to 14. This field will show the name of each cashier.



  • Add a label with the text "Total Sales:" to the Group Footer band and set its font size to 12.



  • Add a field with the value =SUM([SALE_AMOUNT]) to the Group Footer band next to the label and set its font size to 12. This field will show the total amount of sales for each cashier.



  • Add a label with the text "Grand Total:" to the Report Footer band and set its font size to 14.



the label and set its font size to 14. This field will show the total amount of sales for all cashiers.



  • Preview and save your report. You can choose any output format you want, but for this example we will use PDF.



You have just created an end of the day cashier balances report with inpu


About

Welcome to the group! You can connect with other members, ge...

Members

  • ZS Licensekey
    ZS Licensekey
  • Doug Ferrieri
    Doug Ferrieri
  • Herl Wyatt
    Herl Wyatt
  • nguyenbich13697
  • Crack deck
    Crack deck
bottom of page