Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Report Wizard supports most DOCX features. You can place the VTL codes inside core (properties) and content of any DOCX file. All syntax usable in RTF can also be used in DOCX.

A Sample of DOCX Converted from an RTF DocumentImage Modified

...

A Sample of DOCX Converted from an RTF Document.

Limitations when used in Microsoft Office Word document

You cannot use multi-line statements in different objects. If you try to use them in DOCX, an error message will open. See the following example.

Invalid Usage of Multi-line Statement in DOCXImage Modified

 

Image Modified

...

The Error Message of Invalid Usage of the Multi-line Statements in DOCX.

Creating data for multiple columns

#forcol is used for creating data for multiple columns in a row. This statement must be defined in table and can be used in conjunction with the #forrow statement. For example:

Sample elements in MagicDraw Containment TreeImage Modified

...

Sample elements in the MagicDraw Containment tree.

Template Code:

Name
 #forcol($p in $Package)$p.name#endcol

Image Modified

Info

#forcol may create different number of columns in each row. See the example below.

Template Code:

#forrow($p in $sPackage) $p.name#forcol($o in $sorter.sort($p.ownedElement))
$o.name#endcol#endrow

Output:

Image Modified

 

Warning

#forcol must be defined as the first statement in a column because it is parsed and processed before other statements in the column except #forrow. See the example below.

Template Code

Name#set($p = $Package) #forcol($ap in $p)
$ap.name#endcol

Above code will be parsed to 

Name#forcol($ap in $p) #set($p = $Package)
$ap.name#endcol

Output:

Image Modified

So, the template code should be:

Template Code:

Name#set($p = $Package)#forcol($ap in $p) $ap.name#endcol

Output:

Image Modified

Info

#forcol will create dynamic columns in a row. This directive does not create columns for the whole table. See the example below.

Template Code:

Name
 #forcol($p in $Package)$p.name#endcol
  

Output:

Image Modified

Tip

Docx supports at most 63 columns per row (

...

see the following figure).

Docx supports at most 63 columns per rowImage Modified

...

Docx supports at most 63 columns per row.

Creating merged column horizontally for DOCX

ReportWizard provides utility functions for creating table properties. The functions of this module are accessible from templates through $tableprop. In this version, ReportWizard provides only $tableprop.mergeColumns() to create merged columns horizontally in DOCX template.

This statement must be defined in table.


1. $tableprop.mergeColumns(int number)

Merging columns in specified number

Where the parameter is:

  • number - the number of columns to merge. This value has to be of type integer and start from 2.

For example:

Template Code:

Project $tableprop.mergeColumns($Package.size())Packages
#forcol($p in $Package)$p.name#endcol

Image Modified


2. $tableprop.mergeColumns(String stringNumber)

Merging columns in specified number as String

Where the parameter is:

  • stringNumber - the string value of number of columns to be merged. This value has to be of type integer string and start from “2”.

For example:

Template Code:

Project$tableprop.mergeColumns(“3”) Packages
#forcol($p in $Package)$p.name#endcol

Output:

Image Modified

Info

$table.mergeColumns() must be defined as the first statement in the column because it is parsed and processed before other statements in column expect #forrow and #forcol. See the example below.


Template Code:

Project#set($gValue = $Package.size() +
1)$tableprop.mergeColumns($gValue)Packages
#forcol($p in $Package) $p.name#endcolNo Package

Above code will be parsed to 

Project $tableprop.mergeColumns($gValue)
#set($gValue = $Package.size() + 1)Packages 
#forcol($p in $Package) $p.name#endcol No Package

  Output:

Image Modified

 

So, the template code should be:

Template Code:

Project#set($gValue = $Package.size() + 1) $tableprop.mergeColumns($gValue)Packages
#forcol($p in $Package)$p.name#endcol No Package

Image Modified

Tip

$tableprop.mergecolumns() will make a column to be a merged column, it does not change the number of columns in a row. See the following example.


Template Code:

$tableprop.mergeColumns(“5”)Packages  
#forcol($p in $Package)$p.name#endcol  

Output:

Image Modified

The number of columns in the first row is still 3.

...