Simple Class Dataset

  • Last update:  2020-12-17
  • 1.Overview

    The data source of FineReport can come from not only database or text, but also any other type of data.Since FineReport reads the data source through the abstract class AbstractTableData, and all of the above data sources inherit their abstract methods, users can use a self-defined data source as long as they inherit AbstractTableData. The dataset generated by programming is class dataset. 

    2.Principles:

    AbstrctTableData has 5 main methods to be implemented:

    //get count of columns in dataset
    public int getColumnCount(); 
    //get the name of the column of index columnIndex
    public String getColumnName(int columnIndex); 
    //decide if the row of index rowIndex exists.It's difficult to iterate all the data to obtain the total number of rows while processing high volume data. It can be readable if it exists
    public boolean hasRow(int rowIndex);
    //get row count of dataset
    public int getRowCount(); 
    //get the value at (rowIndex, columnIndex) in dataset
    public Object getValueAt(int rowIndex, int columnIndex);

    3.Example

    We define a class dataset below with column names to be Name and Score, values to be  Alex, 15; Helly, 22; Bobby, 99


    3.1 Define Class Data Source

    In the beginning, please refer to launch the designer in IDEA[link] and build the environment. Define a class which inherits AbstractTableData and gets the methods implemented. Check out the following link to get more details: 

    https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/data/ArrayTableDataDemo.java


    3.2 Compile the Class

    Compile ArrayTableDataDemo.java as ArrayTableDataDemo.class

    Copy the class file under the path  %FR_HOME%\webapps\webroot\WEB-INF\classes .In the end, ArrayTableData.class should be placed under %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\data. because the class is in com.fr.data. At this point, class data source has already been defined.


    3.3 Configure Class Dataset

     Click on Class when choosing data source

     

     Choose ArrayTableDataDemo.class in the poped up window 


    3.4 Use Class Dataset

    The class dataset is good to use after the configuration.It works the same way as other types of dataset. The data can be bound to The  cell data columns by drag and drop.

    4. Remarks

     In the situation of remote design, while using the class dataset, both the server and the local need to equip the class file. Otherwise, the compilation and preview will cause error.


    Attachment List


    Theme: Secondary Development
    • 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