Tuesday 24 December 2013

Adding Header and footers in XML Template

in the previous lesson we had learnt that how to create RTF. Now we are going to add Header and Footer to the existing template.
Our template which we had created in the previous lesson is shown below
For the above template we are going to add header and footer
If we want to display anything for every page then we will go to header and footer.
For that in RTF go to VIEW=>Header and Footer which is shown below

Now we are going to write some text in the Header and Footer which is shown below

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output
From the above output we can see that header text and footer text appeared.
For displaying any text or date or page numbers etc.. for every page we can go to Header and Footer

Alternative Method

Microsoft Word does not allow form fields in the header and footer regions of a document. If you require many or complex objects in the header or footer of your report, these regions can become difficult to read or understand. As an alternative, you can create header and footer templates in the body of your RTF template document that can then be called from the header or footer region.
To create a template within your template, simply wrap the contents of the internal template with the following tags:
<?template:internaltemplate name?>
<?end template?>
where internaltemplate name is the name you assign to the header/footer template.
Then in the header/footer region, simply enter the following syntax to call this template:
<?call:internaltemplate name?>
At runtime the contents of the internal template will render at the position of the call.
Example
Assume you have the following XML data:
<REPORT>
<COMPANY_NAME>Oracle</COMPANY_NAME>
<REPORT_NAME> Accounts Payables – Invoice Listing</REPORT_NAME>
<REPORT_DATE>1st January 2005</REPORT_DATE>
<LEGAL_TEXT>Private and Confidential</LEGAL_TEXT>
...
</REPORT>
You want the: COMPANY_NAME, REPORT_NAME, and REPORT_DATE to display in a table in the header of the report as shown in the following figure
Field Form
Field Entry
Description
Template:OraHeader
<?template:OraHeader?>
Declares a template called "OraHeader".
Oracle
<?COMPANY_NAME?>
Placeholder for the COMPANY_NAME
element.
Invoice Listing
<?REPORT_NAME?>
Placeholder for the REPORT_NAME element.
01-Jan-05
<?REPORT_DATE?>
Placeholder for the REPORT_DATE element.
End Header
<?end template?>
Closes the OraHeader template.
In the header of your template, enter the following:
<?call:OraHeader?>
At runtime the OraHeader template will be rendered in the header of each page of the document.

No comments:

Post a Comment