Pentaho 简明教程

Pentaho - Formatting Report Elements

将报告元素放在工作空间中后,可以使用不同的方式对其进行格式化。Pentaho Reporting Designer 提供了各种功能来根据我们的要求对报告元素进行格式化。

Once you have placed a report element in the workspace, it can be formatted in different ways. Pentaho Reporting Designer provides various features to format the reporting elements as per our requirement.

Text Formatting

所有基于文本的元素,例如文本、数字、日期和标签,都可以使用出现在报表画布正上方的格式化工具栏轻松格式化。

All the text-based elements such as text, number, date, and labels can be easily formatted using the Formatting Toolbar that appears just above the Report Canvas.

来看一看下面的截图。在这里,我们已标记并突出显示了三个对象:

Take a look at the following screenshot. Here, we have marked and highlighted three objects −

  1. Selected Report Element

  2. Formatting toolbar

  3. Style Pane tab for formatting the report elements

首先,在工作空间上选择报表元素。此后,可以使用格式化工具栏或样式选项卡窗格中的属性以多种方式对该元素进行格式化。

First of all, select the Report Element on the workspace. Thereafter, you can format that element in many ways using the Formatting toolbar or using the properties from the Style Tab pane.

text formatting

Pentaho Report Designer 允许您向报表数据添加超链接。在这里,我们将举一个通用示例来说明如何在报表中添加超链接。

Pentaho Report Designer allows you to add hyperlinks to your report data. Here we will take a general example to explain how to add hyperlinks in your report.

假设我们已在 employee 表中添加了一个查询以获取字段的 ID、名称和职责,我们还向报表工作空间添加了这些字段。在这里,我们的要求是使用超链接将职责字段的各个值作为参数值传递给 www.google.co.in

Assume that we have already added a query in the employee table to fetch the fields’ id, name, and designation. We have also added these fields to the Reporting workspace. Here our requirement is to pass the individual values of the designation field to www.google.co.in as a parameter value using a hyperlink.

首先,在工作空间中选择职责字段。右键单击它,并从列表中选择超链接。来看一看下面的截图。

First, select the designation field in the workspace. Right click on it and select Hyperlink from the list. Take a look at the following screenshot.

add hyperlink

单击超链接选项后,您将找到一个对话框,您必须在其中提供详细信息,例如超链接位置、URL、目标、参数名称和值。

After clicking the Hyperlink option, you will find a dialog box where you have to provide details such as Type of the hyperlink location, URL, Target, Parameter name, and Value.

请查看以下屏幕截图。这里,我们已标记并突出显示以下 5 个活动:

Take a look at the following screenshot. Here we have marked and highlighted the following five activities −

  1. Provide the type of Hyperlink Location. Generally there are four types of locations − Self − Linking to the same report field. URL − Provide a URL for that reference location. Pentaho Repository − If you install Pentaho Repository, then provide that file URL in the localhost (Login is required). Manual Link − Create a link or a formula manually and provide it as Hyperlink. For this example, we have used URL type location.

  2. Provide the URL of the website or the file. For this option, we have used https://www.google.co.in.

  3. Provide the Target location, that is, _TOP, _BLANK, or _PARENT. We have used “_TOP”. If you want to provide any information to the user when the mouse pointer moves over the hyperlink text, then type the information in the tooltip box which is placed just beside the Target box.

  4. Select the plus (+) symbol to add a Parameter name and value to the parameter list.

  5. Provide a Parameter name and a value to the URL of the Hyperlink. Here we have used “q” as the Parameter name and Designation field as the Parameter value.

最后,单击确定以确认超链接属性。

Finally, click OK to confirm the Hyperlink properties.

add hyperlink 1

单击格式化工具栏中的预览按钮以预览报表。单击预览按钮后,您将找到以下屏幕截图。将鼠标指针放在任何职位值(HR 或 Admin)上,以查看其特定 URL。

Click the Preview button on the formatting toolbar to see a preview of the report. After clicking the Preview button, you will find the following screenshot. Place the mouse pointer on any designation value – either HR or Admin – to see its respective URL.

add hyperlink 2

在此 Pentaho 报表设计器预览中,超链接用于将用户重定向到另一个 URL。为此,您必须通过单击主工具栏上的运行按钮(在以下屏幕截图中标记为“1”)在此 HTML 上运行此报表,并选择其上的 HTML 选项。

In this Pentaho Report Designer preview, the hyperlink is meant for redirecting the user to another URL. For that, you have to run this report on HTML by clicking the Run button on the Main toolbar (marked as "1" in the following screenshot) and select the HTML option on it.

请查看以下屏幕截图。有不同的用于运行报表的选项,但我们选择以 HTML 格式显示报表。

Take a look at the following screenshot. There are different options for running the report, but we have chosen to display the report in HTML format.

add hyperlink 3

选择 HTML 选项后,您将在单独的 HTML 页面中找到报表数据,如下面的屏幕截图所示。单击任何职称值以了解超链接如何在 Pentaho Reporting 中工作。

After selecting the HTML option, you will find the report data in a separate HTML page, as shown in the following screenshot. Click on any Designation value to understand how a hyperlink works in Pentaho Reporting.

add hyperlink 4

Row Banding

Pentaho 报表设计器有一个行条带属性,允许您为报表的交替行着色。让我们看一个之前的示例以了解其工作方式。

Pentaho Report Designer has a row banding property that allows you to color the alternate rows of your report. Let us take our previous example to understand how it works.

将元素添加到工作空间后,单击报表工作空间 → 转到格式菜单 → 选择行条带。请查看以下屏幕截图。

After adding the elements into the workspace, click the report workspace → go to the Format menu → select Row Banding. Take a look at the following screenshot.

row banding

选择行条带选项后,您会找到一个对话框。在此,您可以从下拉列表中选择一种颜色。我们选择了红色和绿色作为交替颜色。现在,单击确定按钮进行确认。请查看以下屏幕截图。

After selecting the Row Banding option, you will find a dialog box. Here, you can select a color from the dropdown list. We have selected red and green as the alternate colors. Now, click the OK button to confirm. Take a look at the following screenshot.

row banding 1

单击预览按钮查看报表如何交替显示行颜色。它将如下面的屏幕截图所示出现。

Click the Preview button to see how your report appears with alternate row colors. It will appear as shown in the following screenshot.

alternate row colors