User's Guide > About the User's Guide > Word and Excel Templates > Excel Templates > Advanced Script Tags and Groovy and Velocity Scripts
Advanced Script Tags and Groovy and Velocity Scripts
While simple property access and JEXL expressions may be sufficient most of the time, more powerful scripts or templates might be needed for some cases.
In these situations, the Excel export can contain more advanced tags that can execute a Velocity scripts.
Advanced tags include:
Tag Name
Description
cb:script
Executes a template using the default script languageVelocity, and puts the
result into a cell.
cb:groovy
Evaluates a Groovy template and puts the results into a cell.
cb:velocity
Executes a Velocity template and puts the result into a cell.
For example, the <cb:groovy>Groovy name:${item.name}</cb:groovy> tag sets the cell to if when the item name is “my bug”:
Groovy name:my bug
The following is another example of using a .
<cb:groovy template="false" silent="false"> email = item.submitter.email; domainR
In the example, the domain name is extracted from the email address of the issues. If the submitter is ajohnson@abccomapny.com, the script will input “abccompany” to the cell.
* 
The following are known limitations of the scripts:
The cb:script tags will use the complete content of the 1st cell as script, even that part which is outside of the <cb:script>...</cb:script> tags!
These tags will ignore and remove all the remaining cells even that the tag spans multiple cells
The cb:groovy tag has some special feature that it can run in two different modes: as template or as script. The template mode means that the script is evaluated as a Groovy Simple Template , which has following main characteristics:
The template is producing a string output (not a date or number).
Bean properties are accessed using the ${bean.property} notation.
The new variables declared inside the template are local, which means they are lost when the template evaluation is completed.
An example of this:
<cb:groovy>Hello ${world}</cb:groovy>
On the other hand, the Groovy template can run in script mode. That mean that the script-text is evaluated as some Groovy code. For example:
<cb:groovy template="false" silent="false">item.submittedAt</cb:groovy>
This differs from the template mode as:
The variables and bean properties are accessed using the simple dot (bean.property) notation, no ${...} text is needed around.
Any variables declared in the script will be available later as beans in the scope. For example:
<cb:groovy template="false">email = item.submitter.email</cb:groovy>

will create an email bean in the scope which later can be used as ${email} elsewhere in the Excel document.
By default the script won't produce any output, which means it won't write anything to cell. However if the silent=false property is set then return value of the script will be inserted to the table cell. This means that it can return date objects or numbers too, like in this example the cell will contain a date data.
Was this helpful?