I. Overview
1. Expected effect
The designer can freely implement language switching, but the report content is fixed, and its language will not change according to requirements.
In some business requirements, it is necessary to switch between Chinese and English for the content of a single page report, as shown in the following figure:
2. Implementation ideas
Judge by formula to change the string in the label and text content.
Change the data source field in the drop-down box and report field content through conditional judgment.
II. Example
1. Data preparation
Create a new built-in data set ZHEN , as shown in the following figure:
Note: The method in this article does not support file data sets, and the field content in the table cannot be obtained by formulas using file data sets.
2. Template design
1) Design of report body
Create a new ordinary report and insert formulas in cells B1 and B2. The specific settings of the cells are shown in the following table:
Cell | Expansion direction | Content | Explain |
B1 | Does not expand | IF($LAN ='EN','SALE_EN','Salesperson') | When the language is Chinese, the cell content is salesperson When the language is English, the cell content is SALE_EN |
B2 | Expand down | IF($LAN ='EN', ZHEN.SELECT(SALE_EN, AREA_CN = $AREA), ZHEN.SELECT(SALE_CN, AREA_CN = $AREA)) | When the language is Chinese, the cell displays the name of the salesperson in the selected region When the language is English, the cell displays the SALE_CN name of the selected AREA |
As shown below:
2) Set the language selection widget
Edit the parameter panel, drag in the label widget, and the widget value selection formula: IF($LAN =='EN','LAN:','语言:') , as shown in the figure below:
The meaning of the formula: when the user selects Chinese, the label becomes 语言:; when the user selects English, the label becomes LAN:.
Drag in the drop-down box widget, change the widget name to LAN , click the data dictionary type to set to Custom , the actual value and display value settings are shown in the following figure:
3) Set the area selection widget
Drag in the label widget, and the widget value selection formula: IF($LAN =='EN','AREA:','地区:') , as shown in the figure below:
Select the drop-down box widget, set the widget name, widget value, data dictionary and other attributes, as shown in the following table:
Attributes | value | Remark |
Widget name | AREA | - |
Widget value | Type: Formula Value: IF($LAN=='EN',ZHEN.FIND(AREA_EN,AREA_CN,$$$),$$$) | When the language is Chinese, the drop-down box displays the value of the selected AREA_CN column When the language is English, the drop-down box displays the value of the selected AREA_EN column |
Data Dictionary | Type: Data query Data set: ZHEN Actual value: AREA_CN Display value: IF($LAN=='EN',ZHEN.FIND(AREA_EN,AREA_CN,$$$),$$$) | When the language is Chinese, the drop-down box displays the value of the AREA_CN column When the language is English, the drop-down box displays the value of the AREA_EN column |
3. Effect preview
Save the template, click the Pagination Preview, the effect is shown in section I-1.
Note: Mobile terminal is not supported.
III. Template download
Click to download the template: Switch_between_Chinese_and_English_in_a_single_report.cpt