Batch Export Excel in the Background

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

    1. Scenario

    The computed result of a report can be variable in different conditions. To save the results of each condition, such as save them into an Excel file, you can carry it out in bulk by invoking the export interface ExcelExporter.


    2. Approaches

    To batch export the results into Excel with codes, the first thing to do is to traverse and load each set of parameter values in para.txt, and pass the acquired values into the template for calculation. Then, export the calculated data into an Excel file, looping until the end of the last parameter group is reached.

    II. Instructions

    The article takes %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc\Primary\Parameter\Parameter.cpt as an example to perform batch export into Excel files in the background.


    1. Parameter Group

    Due to the fact that different parameter groups can bring out different results, it's necessary to obtain all the possible parameter values, which can be derived from a certain table in a database or a file.

    Save the group of parameter values in a text file, such as para.text. Place it into %FR_HOME%\webapps\webroot\WEB-INF\ and ensure the content is formatted as below:

    The case of only one parameter:

    551.png

    For two parameters, use commas to separate two values as follows:

    552.png  


    2. The Batch Export Program

    Please go to the following URL for the complete codes: https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/io/ExportBatch.java

    Note 1: some JARs need to be imported when using APIs to export as different types of files. Please see below.

    • FineReport Default JARs

    • sqlite-jdbc.jar under the directory of %FR_HOME%\webroot\WEB-INF\lib

    • serverlet-api.jar under the directory of %Tomcat_HOME%\lib

    • tools.jar under the directory of %JAVA_HOME%\jdk\lib

    Note 2: when an exported Excel file contains nothing but the format of its template, please confirm whether the above codes for defining the reporting environment are correct or available. Otherwise, the above "no data" issue will occur.

    The aforesaid codes are for reference only. Don't forget to modify those variables, such as report runtime environment and the template name, based on your practical situation.

    Startup the designer. Once the program is successfully compiled and run, two Excel files will be brought to the download directory.


    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