Successfully!

Error!

Sorting String-Type Data

  • Last update:  2024-03-08
  • Overview  

    Version 

    Report Server Version
    FineReport 11.0.3 and later versions

    Application Scenario 

    If the data stored in the dataset are of string type, using the sort function of the designer will sort them following the sort rules of strings, but you want them to be sorted according to the value size, as shown in the following figure.

    Implementation Method 

    1. Modify the field type in the database.

    2. Convert strings to numbers using the TOINTEGER() function.

    Example

    Report Design 

    Create a general report and a built-in dataset, as shown in the following figure.

    The report design is shown in the following figure. Enter No. and Name in cells A1 and B1, and drag the fields into cells A2 and B2.

    Select Cell A2, choose Cell Element > Advanced, click Add Main Sort Order, set Sort Basis to Formula, enter the formula =TOINTEGER($$$), and set Sort Rule to Ascend

    iconNote:
    The setting also applies to Sort After Expansion.

    Effect Display 

    On PC

    Save the report and click Pagination Preview. The effect is shown in the "Application Scenario" section.

    On Mobile Terminals

    Save the report and click Mobile Preview. The effect is shown in the following figure.


    Template Download 

    You can download the example template. Sort string-type data.cpt

     


    Attachment List


    Theme: Report Application
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback