Word Template Report Renderer
Report Parameters (${...})
The word document may contain parameters as normal text elements that are replaced. Those parameters have the form ${ParamName}.
This renderer also supports arbitrary MessageFormat patterns for all input parameters; for example ${Now,date,short} will effectively be interpreted as MessageFormat {0,date,short} with the single parameter Now from the parameter map. For more information about MessageFormat, please consult the MessageFormat javadoc.
There is one predefined property that is always added to the parameter map:
-
${Now}contains the current timestamp and can be used for both date and time display. Since this represents aDateobject, it can be formatted directly using MessageFormat, for example:
${Now,date,short}displays a short date using the user's locale; for example:09.01.12.
Alternatively, a date format can be specified in aSimpleDateFormatcompatible form, for example:
${Now,date,dd.MM.yyyy}resulting in09.01.2012.
This report renderer allows to pass arbitrary parameters to the conversion engine: the parameter map passed to the renderReport() method is forwarded to the report engine. Thus, when placing the parameter Salutation with value "Dear Mr. Smith" into the parameter map when calling this renderer, you can display this value in the document using ${Salutation}.
Adding images is also supported by adding an instance of BufferedImage to the parameter map. This image replaces the entire text node where the parameter was found and is inserted as an inline image. Make sure there's enough place for that image in the template document.
Handling Multiple Languages
You can have this renderer use different documents for rendering depending on a language.There must always be a default template configured which is used if there's no specific template defined for the passed-in language. Additionally you can define a specific template for every language expected.
Templates are read in when the renderer is initialized and are kept in memory by the renderer. Thus, reusing the renderer instance improves efficiency as the document needn't be re-parsed on every call.
defaultTemplate) Supported formats are: DOC, DOCX, RTF and ODF.
The file name is either absolute or relative to the JVMs current directory.
Multiple templates for different languages can be specified with the property template. There must always be a default template.
template) Selectors must be chosen according to the ISO-2-letter language codes, i.e. "fr" for french.
See also description of default-template.
saveOptions)
type: WordTemplateReportRenderer
id: WordTemplateReportRenderer-xxxxxx
displayName:
comment:
properties:
defaultTemplate:
saveOptions:
template: