Different Background Colors by Condition

  • Last update:June 03, 2025
  • Overview

    Problem

    When creating a report in FineReport, you may often encounter the situation where cells/rows/columns need to be displayed in different background colors under certain conditions. So, how can you achieve this effect?

    Solution

    You can add the Background attributes in Condition Attribute to achieve the effect.

    The background setting of Current Cell, Current Row, and Current Column follows the same principle. In this document, Current Cell and Current Row are selected to set the background color as examples for explanation.

    Example One: Current Cell

    Data Preparation

    Create a general report, and create a built-in dataset, E-Commerce Sales Proportion, which records the sales proportion of different products across various e-commerce platforms.

     1.png

    Table Design

    Right-click cell A2, choose Cell Element > Insert Slash, enter E-Commerce|Product, and select Diverge from Top Left to Bottom Right. Enter e-commerce platform names in cells B2 to M2, and drag the data columns into corresponding cells A3 to M3. The following figure shows the table design.

     2.png

    iconNote:
    The width of the table exceeds the default paper size. You can adjust the paper size under Template > Page Setting to ensure the entire table is displayed on a single page during the preview.

    Condition Attribute Adding

    Select cells B3 toM3, add a Background condition attribute, click Edit to select a color, and select Current Cell from the drop-down list.

    Set the conditions for this condition attribute to take effect: Set Type to Common, select Double from the drop-down list, and select AND to connect the two conditions, currentValue Greater than/Equal to 0.5 and currentValue Less than 0.7.

     3.png

    Add six condition attributes in sequence, as shown in the following table.

    Condition AttributeCondition

    Condition Attribute 1

    currentValue Greater than/Equal to 0.5 and currentValue Less than 0.7.

    Condition Attribute 2

    currentValue Greater than/Equal to 0.3 and currentValue Greater than/Equal to 0.5.

    Condition Attribute 3

    currentValue Greater than/Equal to 0.1 and currentValue Less than 0.3.

    Condition Attribute 4

    currentValue Greater than/Equal to 0.05 and currentValue Less than 0.1.

    Condition Attribute

    currentValue Greater than/Equal to 0 and currentValue Less than 0.05.

    Condition Attribute 6

    currentValue Equal to 0.0.

    iconNote:
    The execution order of condition attributes is from top to bottom.

    Effect Display

    PC

    Save the template, and click Pagination Preview. Cell data in different ranges will be displayed in different colors with the same effect as the heatmap, as shown in the following figure.

     4.png

    Mobile Terminal

    The template can be previewed on both the DataAnalyst app and the HTML5 terminal. The following figure shows the effect.

     5.jpg

    Example Two: Current Row

    Data Preparation

    Create a general report, and create a database query ds1 with the SQL statement SELECT * FROM Sales_Volume.

     6.png

    Table Design

    Drag all fields into cells, set corresponding titles, and set Data Setting to List for cell A2, as shown in the following figure.

     7.png

    Condition Attribute Adding

    Select cell A2, click Condition Attribute on the right side, add a condition, select Background from the drop-down list of Attribute, click Edit, select a color, and select Current Row from the drop-down list.

    Set Formula Condition to Formula, click Define, and enter the formula: E2 >= 500, which indicates that when the sales volume is greater than 500, the current row will be displayed in green, as shown in the following figure.

     8.png

    Effect Display

    PC

    Save the report and click Pagination Preview. The following figure shows the preview effect.

     9.png

    Mobile Terminal

    The template can be previewed on both the DataAnalyst app and the HTML5 terminal. The following figure shows the effect.

     10.jpg

    Template Download

    Attachment List


    Theme: Report Features
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy