Sunday, July 28, 2013

Displaying Page Totals

XML Publisher allows you to display calculated page totals in your report. Because the page is not created until publishing time, the totaling function must be executed by the formatting engine.
Note: Page totaling is performed in the PDF-formatting layer. Therefore this feature is not available for other outputs types: HTML, RTF, Excel. Because the page total field does not exist in the XML input data, you must define a variable to hold the value. When you define the variable, you associate it with the element from the XML file that is to be totaled for the page. Once you define total fields, you can also perform additional functions on the data in those fields. To declare the variable that is to hold your page total, insert the following syntax immediately following the placeholder for the element that is to be totalled:
?
1
<?add-page-total:TotalFieldName;’element’?>
where TotalFieldName is the name you assign to your total (to reference later) and’element’ is the XML element field to be totaled. You can add this syntax to as many fields as you want to total.
Then when you want to display the total field, enter the following syntax:
?
1
<?show-page-total:TotalFieldName;’number-format’?>
where TotalFieldName is the name you assigned to give the page total field above and number-format is the format you wish to use to for the display. The following example shows how to set up page total fields in a template to display total credits and debits that have displayed on the page, and then calculate the net of the two fields.
The below picture shows the sample RTF template:









The below picture shows the sample XML tags of the above RTF file:







Now let us take one field like Inv_Amt which is shown below

















Give double click on the field and Provide proper default text and in Add Help Text and in that we are going to write below command
?
1
<?add-page-total:pagetot;’INVOICE_AMOUNT’?>
Which is shown below:

Now we have to display this pagetot(total field name) by using below syntax: -
?
1
<?show-page-total:TotalFieldName;’number-format’?>
Example:
?
1
<?show-page-total:pagetot;’999G999D99’?>
For that we have to place one form field which is shown in below picture:














Provide proper default text and in Add Help Text we are going to write below code which is shown below:
?
1
<?show-page-total:pagetot;’999G999D99’?>































Now our RTF looks like :















Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
The below picture shows output in PDF format.










From the above output we can see that page total.
If there is two or more pages then we can see page total for every page.

No comments:

Post a Comment