Simple Class Dataset

  • Last update:July 20, 2026
  • Overview

    Application Scenario

    In practice, users may need to obtain data through a program. FineReport supports class datasets. After defining a custom class data source, users can add and use a Class dataset under the dataset section.

    This document uses a simple example to explain how to define and use a class dataset. The example creates a custom simple data table through a Java program to generate a report.

    Implementation Principle

    The SimpleTableData abstract class defines attributes and methods related to data sources. To customize a class dataset, users can extend the SimpleTableData class when defining a class. This allows using its methods to define a class data source. Once defined, the FineReport report engine can read the defined data source for report generation.

    Example

    The following section demonstrates how to create a simple and custom class dataset. The data is shown in the following table.

    Name
    Score
    Alex15
    Helly22
    Bobby99

    Preparing the Compilation Environment

    Before compiling the program, create a Java development environment and install a Java IDE such as Eclipse or IntelliJ IDEA.

    Import the FineReport project JAR packages into the IDE project, including:

    All packages under FineReport installation directory/lib,

    All packages under FineReport installation directory/server/lib,

    All packages under FineReport installation directory/webapps/webroot/WEB-INF/lib,

    and tools.jar under JDK. For detailed operations, see Compiling a Java Program.

    Defining a Class Data Source

    Writing a Java Program

    Write the Java program SimpleArrayTableDataDemo.java in the IDE to define a class extending SimpleTableData, and define the data columns and data.

    For complete code, see SimpleArrayTableDataDemo.zip.

    iconNote:

    It is recommended that the package path of the file match the path in the code. If they do not match, ensure that the corresponding folder exists under the project path FineReport installation directory/webapps/webroot/WEB-INF/classes, as described in the section "Importing the Class File." Additionally, manually import SimpleTableData in the code by adding import com.fr.data.SimpleTableData;.

    Compiling the Java File

    After writing the Java program, compile SimpleArrayTableDataDemo.java in the IDE. Once compilation succeeds, the class file SimpleArrayTableDataDemo.class will be generated under the project storage path in the IDE, as shown in the following figure.

    2.2.2 编译 Java 文件.png

    Importing the Class File

    Copy the compiled class file SimpleArrayTableDataDemo.class to the project directory FineReport installation directory/webapps/webroot/WEB-INF/classes/com/fr/data, and restart the report project.

    The class data source is now defined, as shown in the following figure.

    2.2.3 导入 class 文件.png

    iconNote:

    During remote design, the class file corresponding to the class dataset must be placed under the projects of both the local designer and the remote server.

    Download the class file: SimpleArrayTableDataDemo.rar

    Creating a Class Dataset

    Click the    sign, click Class, and select the corresponding class file in the pop-up Class Dataset window, as shown in the following figure.

    2.3 创建程序数据集.png

    After selecting the class file, click OK to complete the class data source configuration.

    Using the Class Dataset

    After configuring the class data source, you can use the custom class dataset in the same way as other dataset types, for example, binding data fields to cells via drag-and-drop, as shown in the following figure.

    2.4 使用程序数据集.png

    Attachment List


    Theme: Secondary Development
    Already the First
    Already the Last
    • 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