I. Overview
1. Problem description
When designing a report, you can insert a slash through the insert slash function of the menu bar, as shown in the following figure:
However, how to insert the slash only when certain conditions are met?
2. Solutions
1) Scheme 1: Enter a slash in the cell, save the report and preview it, use the browser's Developer Tools and locate the slash to find that it is actually a image. As shown below:
Then add a Conditional Formatting> New, set the new value to HTML code, and then use HTML to display the cell content.
2) Scheme 2: You can do the opposite. First insert a slash in the cell, set the display data when the condition is not met, and then display the slash directly when the condition is met.
II. Example
1. Prepare data
Create a new general report, create a new database query ds1, the SQL query statement is: SELECT EMPNAME, POLITICAL, SEX, ORIGIN FROM EMPLOYEE_COPY.
2. Design report
Drag the data column into the cell, and design the report style as shown in the figure below:
3. Scheme 1
1) Copy HTML
Insert a slash in any cell, save the report and preview it, use the browser's Developer Tools, locate the slash, right-click the code, and select Copy>Copy outerHTML. As shown below:
You can also directly copy the code shown below:
2) Add Conditional Formatting
Select cell D2, add Conditional Formatting> New, the value type is String, enter the copied HTML code, select Formula for the condition type, and enter the formula: len($$$)=0. As shown below:
3) Set cell display content
Set the Cell Attributes> Other> Display Content of cell D2 to Display by HTML. As shown below:
4. Scheme 2
Cancel all the settings of Scheme 1, and repeat the City"in column D in column E, and insert a slash in cell E2, as shown in the following figure:
1) Add Conditional Formatting
Select cell E2, add Conditional Formatting>New, the value type is Formula, enter the formula: D2, select Formula for the condition type, and enter the formula: LEN(D2)>0.
That is, when the D2 cell is not empty, the value of the corresponding D2 cell is displayed, otherwise the slash of the E2 cell is displayed.
2) Hidden columns
Hide column D, as shown in the figure below:
5. Effect preview
1) PC terminal
The above two solutions have the same effect, save the report, click Pagination Preview, the effect is as shown below:
2) Mobile terminal
Both the App side and the HTML5 side support two schemes, and the effect is shown in the following figure:
III. Template download
The completed template can be found in:
%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\Interlace color change after
hidden line.cpt
%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\Interlace color change after
hidden line-JS.cpt
Click to download the template:
Insert a slash in the cell according to the condition_Method 1.cpt
Insert a slash in the cell according to the condition_Method 2.cpt