Description
This actionhandler allows you to create and use Excel document templates with values from process variables that usually come from a smartform. The parameter "overwriteExisting" specifies whether existing templates may be overwritten (true
) or whether a new template should be created. Variables from VariablesHelper can also be used with this actionhandler.
In order to create document names based on variables, you can include desired variables in the document name in addition to the document content.
It is possible to insert pictures from the process instance into the Word document. Therefore, special variables are needed in the template. An individual picture can also be inserted with the exact name of the picture, for example: $img{bild.jpg}
. It is also possible to insert all images attached to the instance: $img{addAllimages}
.
Info |
---|
The ExcelTemplateHandler can also be installed in the Smartform as a button to generate a template if required. More information is here. |
Class
Code Block |
---|
com.dooris.bpm.actionhandler.ExcelTemplateHandler |
Parameter
Parameter | Default value | Description | Valid examples | ||||||
---|---|---|---|---|---|---|---|---|---|
| This parameter is used to set the path to the template, so the ActionHandler can search for it in the resources folder. It can be specified absolute or relative to the external file path in the loom.properties. In order to rename the generated PDF, the name of the template itself may contain process variables. Special case: Resolving process variables in the template name Given the template, parameter has the following value:
|
| |||||||
|
| This parameter is used to decide if the documents should be overwritten if the process run by a loop. If the original template is needed, it should be |
| ||||||
| The documentPrefix can be used so that created documents always have the specified value before the template name. |
| |||||||
|
| When the value is set to |
| ||||||
|
| It can be either true or false. If this value is set to true, process variables (which start with "bool") are changed like below:
|
| ||||||
|
| This parameter is used to decide if the boolean variables (true and false) should be replaced with ‘yes and no'. Setting this variable to |
| ||||||
| This parameter is used to determine the document name in the destination folder. This procedure is useful if the name of the created Word document should be different from the template name. The target parameter can contain process variables. Suppose the user wanted to generate two reports in English and German. The Word template in the resource folder has the following name
|
| |||||||
|
| With this parameter all system supported languages can be given in short form(e.g. |
Setup
In order to setup the action hander the below steps are required:
Setup the process
Have or upload a simple workflow
View file name SimpleModel-version-2.zip Import form
View file name 20240130_SimpleModel_v1.json
Upoad the template in tenant admin resources
View file name temp.xlsx
After the setup you should be able to see:
Use case 1: Create a simple template
Select the process,
Upload the images in documents (upload at least an image called “im1.png” and another one )
Start a new instance with the below template
The generated file can be found in the documents section together with the images. The generated file should look like:
View file | ||
---|---|---|
|
In the above example we have included:
Variable substitution,
Conditional formatting,
Adding single images by name, and all images
Using excel functions,
Document prefix,
Document target,
Interpreting number as boolean, boolean as human and translation
Note |
---|
The variables must be the same as in the Excel template. |
Integrating the ExcelTemplateHandler into a HTML-Smartform
The ExcelTemplateHandler can be integrated into a HTML-Smartform as a link, a button, or an image so that the participants can create a template at any time. For this, the following code must be integrated into the smartform:
Code Block |
---|
<button type="button" onbuttonclick="generateFileFromTemplate([{handler:'ExcelTemplateHandler',template:'temp.xlsx',attach:false,open:true,documentPrefix:'Prefix'}])">Generate Excel template</button> |
The "onbuttonclick" attribute defines which functions/parameters the handler should execute. See Parameters sections above.
Important when using HTML-Smartforms
Normally written text will be inherited, whereas variables will be overwritten if marked as ${Variable-ID}
. To overwrite variables with content from the HTML form, you must use the variable's ID, such as ${Variable-ID}
, within the text form fields. An exception to this rule applies to radio buttons, where you should use the variable name, like ${Variable-Name}
, instead of the variable ID.