I. Overview
1. Function
The TOIMAGE function is used to display pictures under a certain path in the report. Support jpg, png, bmp common format pictures, the pictures can be stored in the local disk, can also be stored in the remote server, can also be a picture in the web page.
2. Function Explanation
TOIMAGE(path,cache,width,height)
Parameter | Meaning | Parameter Format |
---|---|---|
path | Picture path, cannot be omitted | "F:/FineReport_10.0/webroot/logo.png" Note: The slash must be / |
cache | Whether to enable the image caching function, it can be omitted, the default is enabled | true turns on, false turns off |
width | Picture width, can be omitted, the original width of the default picture is omitted | Integer: image width in pixels Percentage: Image width zoom ratio |
height | Picture height, can be omitted, the original height of the default picture is omitted | Integer: image height in pixels Percentage: Image height zoom ratio |
Example:
TOIMAGE("D:/1.jpg")
TOIMAGE("D:/1.jpg",false)
TOIMAGE("D:/1.jpg",true,200,300)
TOIMAGE("D:/1.jpg",true,"50%","200%")
3. Precautions
1) Use the TOIMAGE function to display the cell picture template. When you select the menu bar "File>Output>Template (built-in data)", the picture will not be output with it.
2) If the cell property of the TOIMAGE function is used to set "Style>Paragraph Spacing", then the set "Paragraph Spacing" will not take effect when exporting or printing reports.
3) For the picture returned by the TOIMAGE function, the "picture layout" is set to "default". You can choose other layout methods at "Cell Properties> Style> Alignment> Picture Layout".
II. Application Scenario
The TOIMAGE function can directly enter the image path, or reference the image path field stored in the database.
1. Direct Input
Pictures can be stored on a local disk or on a remote server. The image storage location is different, the path is written differently.
Picture storage location | Path | Formula |
---|---|---|
Local Disk | The absolute path of the picture, such as E:/picture/logo-fanruan.png | TOIMAGE("E:/picture/logo-fanruan.png") |
Report server webroot directory | Omit the simplified path of the directory where the project is located, such as help/logo-fanruan.png | TOIMAGE("help/logo-fanruan.png") |
Pictures in the webpage | Picture network address, such as https://www.fanruan.com/images/logo-fanruan.png | TOIMAGE("https://www.fanruan.com/images/logo-fanruan.png") Note: It is recommended to use WEBIMAGE(path) when displaying pictures in web pages, which can improve the loading speed of Web pictures. |
Note: When the report server webroot is a remote server, the designer must switch to the working directory of the corresponding remote server.
2. Referencing a field in the database
1) If the picture is stored in the local disk E, the path is: E:/picture/logo-fanruan.png, and the picture path is stored in the database table, as shown in the following figure:
2) Drag the field "path" to the report cell, select "Advanced" for the cell properties on the right, and enter the formula TOIMAGE($$$) in the "Display Value" position. $$$ represents the current cell value. Steps As shown below:
3) If the path of the picture stored in the database is incomplete, you need to complete the path to display the picture.
For example, if the image in Disk E above is stored in the database as logo-fanruan.png, the formula of "Display Value" needs to be modified to :TOIMAGE("E:/picture/"+$$$).
Note: If the user database server and report application server are separated, the pictures should be stored on the report application server, not the database server.