Pentaho 5.0 Reporting by Example
上QQ阅读APP看书,第一时间看更新

Time for action – creating a new report and creating a table based on data sets

We will create a new report, and later we will create a Table type data source and configure its columns and data types. Finally, we will populate the table with the example data.

  1. Start PRD if it is not yet running.
  2. Create a new report. Remember that there are different ways to create a new report as follows:
    • Choose the New Report option in the Welcome window
    • Click on the following icon in the shortcuts bar:
    • Navigate to File | New
    • Press Ctrl + N
  3. Save the report as 01_Hello_World.prpt using the following icon:
  4. We will define Table as a data source. The Table is a static data source; it is stored with the report's metadata and remains constant. This type of data source is often used for demonstrations, examples, testing, prototyping, and so on.
  5. In the Data tab, right-click on Data Sets and choose Table.
  6. We define three columns in our data sets: Zones, Products, and Quantity.
  7. To create the table, click on the Time for action – creating a new report and creating a table based on data sets icon. By default, this will create a query with the name set as Query 1 and with two columns ID and Value. We will do the following:
    1. We will change the query's name to ZoneProductQty.
    2. We click on the heading of the ID column and press on the Time for action – creating a new report and creating a table based on data sets button to eliminate it.
    3. We repeat this process now for the heading of the Value column.
    4. We press on the Time for action – creating a new report and creating a table based on data sets button to add a new column. Next, we double-click on the heading of this column to modify it. We give it the name Zones and then click on the Time for action – creating a new report and creating a table based on data sets button and choose class.java.lang.String as Zones will have a String type data.
    5. We follow the same steps to create another column with the name Products using the String data type (class.java.lang.String).
    6. We follow the same steps to create another column with the name Quantity using the Integer data type (class.java.lang.Integer).
    7. After following these steps, we will obtain a result like this:
  8. Next, we will populate the table with data.
  9. To do so, we press on the Time for action – creating a new report and creating a table based on data sets button and fill in the values that correspond to each column. Each time we have to create a new row, we press on the Time for action – creating a new report and creating a table based on data sets button. We need to populate the table with the data that is shown in the following screenshot:
    Note

    Another way of populating the table with data is by pressing the Import Spreadsheet button. With this option, we can extract data from a spreadsheet.

  10. Press OK to save the changes and return to the previous screen. Now we can see how our new data source turned out in the following screenshot:

What just happened?

Initially we created a new report, and then we created a data set of the type Table. We added three columns (Zones, Products, and Quantity) to the table and defined its data types. Finally, we populated the table with some example data.