条件によってセルに斜線を入れる

  • 作成者:ayuan0625
  • 編集回数:7次
  • 最終更新:FRInternational 于 2021-05-17
  • 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:

    1.png

    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:

    2.png

    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 ordinary report, create a new database query ds1, the SQL query statement is: SELECT EMPNAME, POLITICAL, SEX, ORIGIN FROM EMPLOYEE_COPY.

    2.png


    2. Design report

    Drag the data column into the cell, and design the report style as shown in the figure below:

    3.png


    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:

    5.png

    You can also directly copy the code shown below:

    <img style="border:0;width:72px;height:17px;" src="data:image/png;base64,iVBORw0KGgoAAA ANSUhEUgAAAEgAAAARCAYAAAB+bOp4AAABg
    ElEQVR4nO3YQUeGURCG4am+JIlIKaKIIooWUUQRRYtoEUUUUUTRIooooo iiRRRRRBFFiyiiaBFRtIgiiiglleoHdI/Z1C+YWXwP1/5xOO87c0RE3nGGObQhV5L
    5l0w0YAIH+MQ1VtCNErdmQZOGagxhG 094xBYGUYVUt3ZBU4oerOIGH9jHOOqR4VctZvLQjnmc4wenmEUrcvyqxUwWmjCJI3zhCkvoQpFftZhJoAYj2MELHrCBA
    VQgxatc 1JShD2u4wxv2MIo6pPtVi5kCdGARF/jGCabRgmy3ZkGjB9IsdkDHYgd2KXaAepCFftViRq9crdgV1KuoV1Kv5rrYVS13axY0+l HXj3u/2Mf+Hq/YFf
    sZ6E8h4dYuaHR86BQbJ3Ss0PFCx4wpsbEjy61Z0OiAqoPqjNjgqt8xHWQXxAbbfL9qMaMrkK5CY2Krkb5c3 IqtTL1iK1Qyf6JLdqXY0r0ptoQ/iy3lw2JLeppb
    u6ApFnvWWRZ75tHnnkOx55/GX7b6R+0E0Y0oAAAAAElFTkSuQmCC"
    >

    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:

    6.png

    3) Set cell display content

    Set the Cell Attributes> Other> Display Content of cell D2 to Display by HTML. As shown below:

    7.png


    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:

    8.png

    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.

    9.png

    2) Hidden columns

    Hide column D, as shown in the figure below:

    10.png

    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

    Attachment List


    Theme: 帳票機能応用
    既に最初
    既に最後
    • Helpful
    • Not helpful
    • Only read