replaceListVariable

replaceListVariable

BASIC / ADVANCED / PREMIUM

Replaces a single variable within a list by a list of items.

Description
public void replaceListVariable(String variable, ArrayList listValues)
public void replaceListVariable(String variable, ArrayList listValues, OptionsReplaceListVariable options)

This method is designed to generate a Word list with an, a priori, indetermined number of items.

Parameters

variable

The name of the variable that you want to replace by a list of items.

listValues

An ArrayList with the values (WordFragments) you want to use to populate the list.

options

The possible keys and values of this array are:

Option Type Description
firstMatch boolean If the variable appears more than once within the Word document and firstMatch is set to true, Javadocx will only replace the first occurrence of the variable within the Word document.
target String Possible values are: document (default), header, footer. This option sets the scope of the replacement procedure.
parseLineBreaks Boolean If true (default is false) parses the line breaks to include them in the Word document.
type String inline (default) or block; used by WordFragment values.
Code samples

Example #1

The resulting Word document looks like: