Documente Academic
Documente Profesional
Documente Cultură
Individual Columns:
<?TRX_NUMBER?>, <?CUSTOMER_NAME?>, <?TRANS_AMOUNT?>
Group Tag
<?for-each-group:ROW;./YEAR?><?sort:YEAR?>
<?YEAR?>
<?for-each-group:current-group();./MONTH?>
<?MONTH?>
<?for-each:current-group()?>,<?INDUSTRY?>, <?SALES?>, <?end for-each?>
<?end for-each-group?>
<?end for-each-group?>
I Table 3: If you would like a striped effect on your rows this can be achieved in the template. We now use two almost
identical data rows in the table. The native XSL position() function is used to assign each row a numeric value, an if
statement is then used to test the value, so at the beginning of each row we get an if statement:
1st Row: if:position() mod 2=0
2nd Row: if:position() mod 2=1
The position() function will return a number for the row of data starting at 1. The mod or modulus function will
return a 0 or a 1 depending on the result e.g. 2 mod 2 returns 0 and 3 mod 2 returns a 1. So we shade each row as
required and add the if statement and at runtime the rows will be alternately shaded, in this case white and gray.
Repeatable Row Headers
If your invoices break across a page and you want to repeat the column header row this can be achieved using
MSWords functionality.
1. Highlight the header row
2. Table > Table Properties
3. Under the Row tab select the Repeat as Header row at the top of each page
If the invoices table breaks across a page the header row will be repeated.
Now lets combine the Suppliers with their Invoices, we will create an output that lists each Supplier and then their
Invoices.
Report Totals
Similar to the supplier totals we can create placeholders for the report totals, these are contained in the XML but can also
be calculated.
<?ENT_SUM_REP?> and <?ACCTD_SUM_REP?>
<?sum(ENT_AMT)?> and sum(ACCTD_AMT)?>, to ensure that the calculation is applied to the whole data set ie for all
suppliers we place the table after the closing End Supplier field.
string format-number(number,format,[decimalformat])
Parameter Description
Number Required.Specifies the number to be
formatted
Format Required. Specifies the format pattern.
Here are some of the characters used in the formatting pattern:
# (Denotes a digit. Example: ####)
0 (Denotes leading and following zeros. Example: 0000.00)
. (The position of the decimal point Example: ###.##)
, (The group separator for thousands. Example: ###,###.##)
% (Displays the number as a percentage. Example: ##%)
; (Pattern separator. The first pattern will be used for positive numbers and the second for negative numbers)
Decimalformat Optional.
So for example to format the entered amount for thousands and 2 decimal places we would use the following in the
formfield:
format-number(ENT_AMT, "###,###.00" ) which would convert 1234.5 to 1,234.50
If you have negative numbers these are supported too in the format:
format-number(ENT_AMT, "###,###.00";"(###,###.00)" ) the second format denotes how the negative number should be
displayed, note the semi colon separating the formats. So -1234.5 would become (1,234,50)
To handle thousand/decimal delimeter formatting you need to do a little work on your template. XSL supports any
delimiters but it needs to be told what to use. You do this by declaring the decimal format in your template thus:
<xsl:decimal-format name="Euro" decimal-separator="," grouping-separator="." xdofo:ctx="begin"/>
Name is the name you give you format, this can be referenced from your format-number calls
decimal-separator this is the character you wish to use as the decimal point
grouping-separator this is the charater you wish to use to denote the thousand separator.
There are several other options that can be set but these are the basic two.
Please note the use of the xdofo:ctx=begin this is an advanced feature which forces the decimal format declaration to
the root of the template no matter where it is put in the physical RTF.
So when we call the format function this time we use:
<?format-number(ACCTD_AMT,'#.###,00', 'Euro')?>
this time 1234.5 will become 1.234,50 as expected. Note the format string has changed this time.
The other alternative is to use MSWords native field formatting. If you open one of the fields below youll notice that
there is a field type drop down list that includes Number as an option. You can select this, then select the number
format you require.
XDO Formatting once finalized XDO will format the numbers and dates according to runtime locale settings. Details to
follow.
In this template the
Entered Amt uses <?format-number(ENT_AMT,"#,###.00")?>
Accounted Amt uses <?format-number(ACCTD_AMT,"#.###,00","Euro")?>
Supplier totals use the MSWord formatting
Variable Declaration and calling:
<?xdoxslt:set_variable($_XDOCTX, 'x', 1)?> <?xdoxslt:get_variable($_XDOCTX, 'x')?>
Running Totals
<?xdoxslt:set_variable($_XDOCTX, 'RTotVar', 0)?>
Page Totals
<?add-page-total:pt;'ACCTD_AMT'?>
<?show-page-total:pt;'#,##0.00'?>
Repeating Header
<?for-each@section:G_CUSTOMER?>
IFUse the for-each@section to repeat the header inforamtion across pages of the output document. In this case the Customer Name will
be repeated if the line information runs across more than one page, the page numbering will also be reset