Create Class Report

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

    From the previous section, we get to know that the web report refers to a class that implements the Reportlet interface. It is coded and can be directly visited on the Web browser.

    In the previous section, users generate web reports by reading the cpt file. To help users understand the core of web report, in this section, we will introduce how to create web reports.

    2. Example

    2.1 Create a Report

    Create a class CreateReportDemo, which inherits abstract class cpm.fr.web.Reportlet, implements the method createReport(ReportletRequest arg0), and returns a workbook.

    // Create a workbook and add a worksheet to it.
    WorkBook workbook = new WorkBook();
    WorkSheet sheet1 = new WorkSheet();
    workbook.addReport(sheet1);
    return workbook;


    2.2 Insert Cells

    From [Basic knowledge], we notice the worksheets consist of cells. Let's insert cells in sheet1, edit cell content and set the cell formats.

    Insert a cell with row number 1 and column number 1 ,which is A1. The value can be FineReport:

    TemplateCellElement CellA1 = new DefaultTemplateCellElement(0, 0,"FineReport");


    Set the cell format, font Arial, bold, size 20 and in red.

    Style style = Style.getInstance();
    FRFont frfont = FRFont.getInstance("Arial", 1, 20.0F, Color.red); 
    style = style.deriveFRFont(frfont); 
    CellA1.setStyle(style);

    Set the column width to be 150px, the height of row 0 to be 35 px:

    sheet1.setColumnWidth(0, new OLDPIX(150.0F)); 
    sheet1.setRowHeight(1, new OLDPIX(35.0F));

    Now a simplest web report is good to use! Check out the link below to get more details:

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


    2.3 Save and Preview

    Users need to compile Java source file, save CreateReportletDemo.class to application %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\demo, and start up the server. To view the defined  web report, simply type in http://localhost:8075/webroot/decision/view/report?viewlet=com.fr.demo.CreateReportletDemo in the browser.


    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