I. Description
Application scenario: a chart field and a common field should be displayed in a cell hierarchically. For example, a field holds a picture, and B field holds some strings.
The background is a field A, and the displayed content is the value of B field, which is similar to a equal layer of PPT. The lower layer picture is the background, and the upper layer displays finereport string, as shown in the following figure:
II. Implementation ideas
Finereport can be implemented through custom functions. Define two parameters name and image to receive the fields in the template respectively, and then return an image with name to display the text on the image.
III. Steps
1. Writing custom functions
For the code of defining stringimage, see:
2. Compiling custom functions
Put the compiled StringImage.class in
%FR _HOME%\webapps\webroot\WEB-INF\classes because StringImage.java Belongs to package com.fr.function So StringImage.class Need to put under the directory
%FR _HOME%\webapps\webroot\WEB-INF\classes\com\fr\function.
3. Registering custom functions
After generating the class of the function, you need to register in the designer to use the function. Open server > function manager and select the stringimage class just defined, as shown in the following figure:
The function name can be customized, and the use description of the function can be added, as shown in the above figure.
4. Using custom functions
After the custom function is registered, it can be used directly when making reports.
1) First of all, a new table needs to be created in the database to store the contents of pictures and words (see uploading pictures for the method of uploading pictures to the database), as shown in the following figure:
Note: the built-in SQLite does not support displaying pictures.
2) Making templates
Drag cell A1 into the name field, cell B1 into the picture field, and cell A2 into the formula = stringimage (A1, B1), as shown in the following figure:
Save the template preview to achieve the effect of picture below and text above, as shown in the following figure: