上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.
- Start PRD if it is not yet running.
- 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
- Save the report as
01_Hello_World.prpt
using the following icon: - We will define
Table
as a data source. TheTable
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. - In the Data tab, right-click on Data Sets and choose Table.
- We define three columns in our data sets:
Zones
,Products
, andQuantity
. - To create the table, click on the 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:
- We will change the query's name to
ZoneProductQty
. - We click on the heading of the ID column and press on the button to eliminate it.
- We repeat this process now for the heading of the Value column.
- We press on the 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 button and choose class.java.lang.String asZones
will have aString
type data. - We follow the same steps to create another column with the name
Products
using theString
data type (class.java.lang.String
). - We follow the same steps to create another column with the name
Quantity
using theInteger
data type (class.java.lang.Integer
). - After following these steps, we will obtain a result like this:
- We will change the query's name to
- Next, we will populate the table with data.
- To do so, we press on the button and fill in the values that correspond to each column. Each time we have to create a new row, we press on the 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.
- 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.