This chapter describes creating RTF templates in BI Publisher using the Template Builder for Word add-in.
This chapter includes the following sections:
The Template Builder is an add-in to Microsoft Word that simplifies the development of RTF templates. While the Template Builder is not required to create RTF templates, it provides many functions that increase productivity.
The Template Builder is tightly integrated with Microsoft Word and enables you to perform the following functions:
The Template Builder automates insertion of the most frequently used components of an RTF template. RTF templates also support much more complex formatting and processing. For the full description of RTF template features, see Chapter 4, "Creating RTF Templates."
The Template Builder installation provides samples and demo files to help you get started. The demos can be accessed from the Windows Start menu as follows:
Select Start , Programs , Oracle BI Publisher Desktop , and Demos .
You can also access the demos from the BI Publisher\BI Publisher Desktop\demos folder where you installed BI Publisher Desktop (for example: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\demos).
The following demos are provided:
The sample files are located in the BI Publisher\BI Publisher Desktop\Samples folder. The Samples folder contains the subfolders:
The eText, PDF, and Excel template samples can be used as references to create these types of templates. The Template Builder is only available for the RTF templates. The RTF templates folder contains eight subfolders to provide samples of different types of reports. Refer to the TrainingGuide.html located in the RTF templates folder for additional information on what is contained in each sample.
The following list describes prerequisites and limitation for this feature:
Note: See System Requirements and Certification for the most up-to-date information on supported hardware and software.
This section describes how to get started. It contains the following topics:
When you open Microsoft Word after installing the Template Builder, you see the Oracle BI Publisher menu.
For versions of Microsoft Word prior to 2007, the menu and toolbar are displayed as shown in Figure 5-1.
Figure 5-1 Display of the Menu and Toolbar in Versions of Microsoft Word Prior to 2007
For Microsoft Word 2007 users, the BI Publisher commands are displayed in the ribbon format, as shown in Figure 5-2.
Figure 5-2 BI Publisher Commands Displayed in the Ribbon Format
Use the menu (or toolbar) to perform the following:
You can build and upload the template using a direct connection with the BI Publisher server, or you can build and upload the template in disconnected mode.
To work in connected mode:
To work in disconnected mode, you must have a sample data file available in the local work environment.
To work in disconnected mode:
Note: The Template Builder also supports using XML Schema to design an RTF template. However, because the schema contains no data, the preview of the report also contains no data.
The data model defines the XML format that is merged with the RTF template. The Template Builder requires sample data to build the template. You must load sample data to use most of the template builder functionality.
If you are not connected to BI Publisher, then use the procedure in Section 5.3.1, "Loading XML Data from a Local File." If you are connected, then use the procedure in Section 5.3.2, "Loading Data from the BI Publisher Catalog."
One method of loading data to the Template Builder is to save a sample of the report data to a local directory.
If you do not have access to the report data model, but you can access the report, then you can alternatively save sample data from the report viewer.
To save data from the report viewer:
The Load Data group from the Oracle BI Publisher menu enables you to select and load the saved XML file to the Template Builder.
You can connect directly to the BI Publisher Server to load the BI Publisher report data to the Template Builder to use as sample data for designing layouts. You can also download an existing template to modify it.
To connect to BI Publisher and load a data source:
This section includes the following topics:
This dialog enables you to select data elements from the data source and insert them into the template.
In the Insert group select Field to open the Field dialog. The dialog shows the structure of the loaded data source in a tree view, as shown in Figure 5-4.
Figure 5-4 The Field Dialog
Select a field that represents a single data field (a leaf node of the tree) and select Insert (you can also insert the field by dragging and dropping it into the document, or by double-clicking the field). A text form field with hidden BI Publisher commands is inserted at the cursor position in the template. You may either select and insert additional data fields or close the dialog by clicking the Close button.
The Insert Field dialog fields are described in the following sections:
For an XML document with a large and complicated structure, use the find functionality to find a specific field. Enter a partial string of the field name you are searching into the Find field and click Find Next . The next occurrence of a data element that includes the search expression is selected. Click the Find Next button again to see the next occurrence.
When you select a field name in the tree view, an example value for this field is shown.
This check box is only needed if you are using the template in a language that prints the characters from right to left, such as Arabic or Hebrew. Use this feature to force left-to-right printing for fields such as phone numbers, addresses, postal codes, or bank account numbers.
This feature enables you to perform aggregation functions on data fields, such as sum, average, count, minimum, and maximum.
For example, if you select sum for a data field, then the field shows the sum of all occurring values for this data field, depending on the grouping.
It is important to understand the grouping context (marked by G and E form fields) to know exactly which fields are accumulated. If you insert a data field with an accumulation function into a repeating section (marked by G and E processing instruction form fields), you must select On Grouping to accumulate the data for the occurrences within the group. If you do not want the accumulation to be restricted to the group, you must place the accumulation field outside the group.
Figure 5-5 shows an example.
Figure 5-5 Grouping Context Example
Also note that the data field must be a valid XSL number for the accumulation functions to work. Formatted numbers cannot be processed by BI Publisher (for example a number using a thousands separator: 10,000,000.00 cannot be processed).
For more information on groups in s template using the Template Builder, see Section 5.4.5, "Inserting a Repeating Group" and Section 4.4, "Defining Groups."
The Insert Table Wizard enables you to create standard reports. On the Insert menu select Table Wizard and complete the following steps:
Start by selecting the basic report format. Choose from Table , Form , or Free Form . Figure 5-6 shows examples of each format.
Figure 5-6 Examples of Table, Form, and Free Form Formats
An XML document can include multiple grouped data sets. For example, a purchase order XML document may contain header level information, lines, shipments and contacts.
In this step, select the data group that contains the data that is required for the table.
For example, in the Balance Letter sample RTF template (found in the Template Builder installed files under Oracle\BI Publisher\BI Publisher Desktop\samples\RTF Templates), the sample XML file contains three data groups as follows:
The Table Wizard presents a list of the available data groups in the XML data file. Select the group that contains the data fields for the table.
Figure 5-7 shows the Table Wizard Step 2: Selecting Table Data.
Figure 5-7 The Table Wizard Step 2: Selecting Table Data
To build a table to list the invoices contained in the data, select:
as the data set.
The Table Wizard presents the data fields from the selected data set.
Figure 5-8 shows the Table Wizard Step 3: Selecting Data Fields.
Figure 5-8 The Table Wizard Step 3: Selecting Data Fields
Use the shuttle buttons to select the data fields to show in the table. Use the up and down arrows to reorder the fields after selecting them.
This step enables you to regroup the data by a particular field. This is optional.
For example, if you are building a table of invoices, you may want to group all invoices of a particular type or date to be grouped together in the report.
Figure 5-9 shows the Table Wizard Step 4: Grouping the Table.
Figure 5-9 The Table Wizard Step 4: Grouping the Table
There are two options for grouping: Group Left or Group Above. Group Left creates a nested table. The Group By field displays to the left in the outer table. Group Above creates a new table for each new value of the group by field, displaying the value of the group by field as a table title.
Group Left groups the group by element occurrences together, as shown in Figure 5-10.
Figure 5-10 Results of the Group Left Option
Group Above shows the result as a table with a header, as shown in Figure 5-11.
Figure 5-11 Results of the Group Above Option
When you select an element to group by, BI Publisher sorts the data by the grouping element. If the data is already sorted by the grouping element, then select the Data already sorted check box. This selection improves performance.
Use the Break option to insert either a Page break or Section break after each occurrence of this group. Note that a Section break can only be created on the top-level group. The subsequent grouping options only display the Page break option.
A page break starts the next group on a new page; a section break starts the next group on a new page, reset page numbering, reset headers and footers, and reset any running calculations for each occurrence of the group.
You can sort the data in the table by up to four different fields. Select a field and then define the sorting order (ascending or descending), and select the correct data type for the field. For example, if text is selected, "12" comes before "2" (alphanumerical order). If number is selected, "2" comes before "12".
Figure 5-12 shows the Table Wizard Step 6: Sorting the Table.
Figure 5-12 The Table Wizard Step 6: Sorting the Table
Click Finish to create the table and insert it to the Microsoft Word document.
Customize the table by changing fonts, colors, column sizing, borders, shading, and so on, using Microsoft Word formatting commands.
The Insert Table/Form dialog is the most flexible tool of the template builder. It allows you to perform the following tasks:
The Insert Table/Form dialog shows you two tree view panes. The left pane shows the data source structure, while the right pane shows the elements that are copied to the template when you click the Insert button.
First select the data fields to insert in the template and then define how to format them. Drag an XML element from the left Data Source pane to the right Template pane. If the XML element has children, you see a pop-up menu with the following options:
Select Drop Single Node if you want to move only the selected node or Drop All Nodes if you want to move the node and all its children.
If you drag an additional data field from the left Data Source pane to the right Template pane, it is either inserted at the same level (Same Level) or below the node (Child) where you release the node. The Insert Position box defines where the node is inserted.
If you use the left mouse button for drag and drop, then the node and all children are copied. However, if you use the right mouse button for dragging, a dialog is displayed when you release the mouse button. The dialog gives you the option to copy either only the selected node or the selected node and all children.
When you select an element in the right Template pane, you see its properties as well as a preview of how the node is rendered. There are two kinds of nodes:
Data Field nodes (leaf nodes) do not have any child nodes. They represent simple attributes such as the total amount for an invoice or the subtotal for a purchase order line.
Data Group nodes (parent nodes) are nodes that do have child nodes. Typically, they do not represent data attributes, but groups of data - such as an invoice, a purchase order, a purchase order line or a shipment.
If a Data Field node is selected, its properties are shown in the Properties pane. You have the following options to describe how the Template Builder should show the field:
The order in which the data elements are shown reflects the order of the columns in the table. If you want to reorder the columns, change the Insert Position box from Child to Same Level. Then drag the elements into the correct order.
If a Data Group node is selected, its properties are shown in the Properties pane. You have the following options to describe how the Template Builder should render the group:
Tip: To insert a page break before the first occurrence of an element, use Microsoft Word's page break command.
Once you have dragged all data fields over and defined the layout, select the Insert button to place the tables and forms at the cursor position in the document.
You can group any Data Group node, by any of its child Data Field Nodes. For example if you have sales data for multiple quarters, you may want to show the sales data organized by quarter. In this case you would group the sales data rows by the quarter element.
Assume the following structure:
Sales Transaction Quarter Customer Amount
To group the child nodes of a node (Sales Transaction), you select one of the child nodes (Quarter) as the grouping property of the parent node (Sales Transaction). The Template Builder makes this node (e.g. quarter) the parent of the other child nodes (Customer and Amount).
The new structure looks like the following:
Sales Transaction Quarter Customer Amount
The grouping criterion (Quarter) now behaves like any other Data Group Node with children. That means that you can define the layout of its children using the Create As Table, Style, Label, Grouping, and Show Grouping Value properties.
The Insert Table/Form Dialog creates two kinds of form fields:
Form fields representing data elements are replaced with the data when the template is processed. Form fields indicating repeating sections are shown as for-each and end for-each in the document.
If you have selected the Abbreviated form field display option, then the for-each and end for-each form fields are displayed as F and E. The section of the document encapsulated by these two elements is repeated, if the associated data element is repeated in the data.
Use the Chart dialog to insert a chart into a template.
Figure 5-13 shows the Chart dialog.
Figure 5-13 The Chart Dialog
BI Publisher supports a large variety of chart types. Expand the Type list to select the chart type for this template.
Drag and drop the data value you want to measure to the Values field (for example, SALES). You can select multiple Value elements (measures).
The Values field changes depending on the Chart Type that you select:
You can choose to aggregate the Values data as a sum, a count, or an average.
Drag and drop the data element for which you want to see the Value charted (for example, Year). Select Group Data to group the occurrences of the label element before rendering it in the chart. For example, if you are charting Sales by Year, then selecting Group Data accumulates the values for Year, so that only one occurrence of each year is displayed in the chart. If you do not select Group Data, then the value for every occurrence of Year in the data is plotted separately.
If you want to add a series element to the chart, then drag and drop the element to display as a series. Each value is displayed as a new color in the graph.
Select this box if the chart is inside a grouping and you want the chart to display data only for the occurrences of the data elements within the group.
Select a color scheme and style for the chart.
The properties region enables you to change value and label display names, select color, font, and other display options for the chart. The properties list changes depending on the chart selection.
Click Preview to display the chart with the sample data.
By default the data is grouped by the Value element and aggregated by sum.
If you deselect the Group Data check box, the each occurrence of the value element is charted and aggregation functions are not available.
To edit a chart that you have already inserted into the template, right-click the chart and select BI Publisher Chart from the menu. This invokes the chart dialog to enable you to edit the chart.
To insert a repeating group:
Select this check box to use the Absolute Path to the element in the XML structure. This is important if the data contains the same element name grouped under different parent elements.
Select a field from the list by which you want to group the data. If you just want to create a simple loop, do not select a group by element. Selecting a group by element actually regroups the data into a new hierarchy based on the group by element.
Use this option to create either a Page break or Section break if you want to insert a break after each occurrence of this group.
A Section break can only be created on outer groups that surround the whole document. If the selected field is not an outer group, the Section break option is not available.
Note also that when you insert a section break, the page numbering is reset, headers and footers are reset, and any running calculations are reset for each occurrence of the group.
Note: You can set the default display text as Descriptive or Abbreviated using the Options tab. Figure 5-15 shows the Advanced tab of the BI Publisher Properties dialog.To create a group around an existing block of text or elements in a template:
To insert a pivot table: