Reporting – Pentaho Tools
Browsing through Pentaho’s downloads section can be a bit intimidating. With such a wide array of products and tools, it’s a little hard at first to figure out the best way to start writing reports. So, I thought I’d post an entry on what I’ve found to be the most useful development environment for creating and editing reports.
Report Components
Pentaho reports follow a basic Model-View-Controller pattern. In it’s simplest form, a report consists of a .xaction file, which contains the report’s business logic, and a .xml file, which contains the report’s presentation logic. Optionally, .properties files can be used to include internationalized messages.
Main Tools
The two most important tools are the Report Designer and The Design Studio. Both can be downloaded from the Pentaho downloads section. I’ve been using the 1.7.0 RC2 versions of both, and both tools are very easy to install. In both cases, just unpack the zipped archive, and run the executable available (can be .exe, .bat, or .sh, depending on your operating system).
You’ll want to use the Report Designer to modify the view of your reports (.xml files), and the Design Studio for everything else. Before we get into the details of that, let’s first set up our environment.
Getting Setup
Once installed, the Report Designer requires no additional setup, but the Design Studio does. The Design Studio is basically an Eclipse development environment with a series of plugins geared towards fine tuning report files. To get setup, once it’s running, do the following:
- Go to File->New Project
- Select General->Project
- Name the Project Pentaho Solutions
- Uncheck the Use default location checkbox, and input the path to your pentaho-solutions directory.
- Click Finish
Start Creating Reports
Now you can start reporting. I’ve found it most useful to always start with the Report Designer, because it is the easiest way to get a template up for your report even if you need to mold it later on with the Design Studio.
To start a new report, once the Report Designer is running, click on the Go button in the Step 1. Create New Report box. This will open up the Report Design Wizard. Follow the steps to create a basic outline for your report. All of this information can be changed later, so don’t worry if you need something more specific than what is provided.
TIP: Since you may want to fine tune your database query later on anyway (such as inject inputs from the user into your query syntax), you don’t even have to specify a complex of the query here. The most important part is specifying all of the columns you’d like to report on in your query so that it will automatically generate the columns to report on, so something like
SELECT 'a' AS COL1, 1 AS COL2 FROM TABLE
is fine for now. Later you can use the Design Studio to fine tune the query, as long as you make sure that the column aliases match up.
Once you are done with the Report Design Wizard, you can click the “Ok” button and you should see the outline of your report. If you do not see the outline of your report, you may have to click on the “Design” button at the bottom of the Report Designer preview window.
Now it’s a good idea to publish what you have so far. To do so:
- 1. Go to File->Publish
- 2. Input a path and name for the report’s .xml file (this should point to somewhere in your pentaho-solutions directory). All of the files for your report will have this name with a different extension (.xml, .xaction, .properties).
- 3. Check the Publish XAction File box. This will automatically populate the XAction File name.
- Give the report a title and description.
- 4. Select xml in the Type drop down menu. This will allow the user to choose the output type of the report.
- 5. Click “OK”
Now you can open your .xaction file in the Design Studio and start editing it. You may have to first refresh your file tree in the Design Studio by right clicking on the root directory and clicking Refresh.
From here on out, it’s best to only use the Report Designer for modifying the .xml file. So, when you publish from the Report Designer after the initial publish, DO NOT check the Publish XAction File box, since this will overwrite any changes to your .xaction file.
Well, that does it for a basic workflow for creating and editing reports. Below is some useful information regarding the Report Designer and Design Studio.
Report Designer
The Report Designer is mainly a tool for designing the look and feel of your report. You can add new elements to your report by dragging them from the Palette on the left side and into your report. You can also reference variables passed from your .xaction as follows:
$(variableName)
where “variableName” is the name of your variable. For more information on the Report Designer, see http://wiki.pentaho.com/display/Reporting/Report+Designer.
Design Studio
The Design Studio lets you use a GUI to edit your .xaction file so you don’t have to do it by hand. A very useful component to the .xaction is the ability to embed JavaScript processing, which can be used to build a query or prepare inputs for display. The JavaScript can also reference Java classes by specifying them with a fully qualified name. For example,
var date = new java.util.Date();
will create a new Date object. You can also pass variables to your report view by clicking on the Define Process tab of your .xaction file, then clicking on the report Process Action and adding Report Parameters. For more information on the Design Studio, see http://wiki.pentaho.com/display/studio/Getting+Started+with+Design+Studio.
Summary
So, the basic workflow of creating a new report is as follows:
- Use the Report Designer to start a basic outline of the report, and publish all of the report’s files (.xml and .xaction included) to your solution directory.
- From then on,
- Use the Report Designer to only modify and publish the .xml file of the report.
- Use the Design Studio to modify all other files, most importantly, the .xaction file
-Giovanni
Filed under: tutorial | 1 Comment
Tags: pentaho, reporting
Hi,
I am just planned to use this tools.. the info give here is really useful.
Thanks for your detail explanation on this tools. Very useful for beginners
Thanks,
Kalai.