JS Toolbar Buttons Only Export a Single Format File

  • Last update:  2020-12-24
  • I. Description

    FineReport supports the export of reports in various formats, and reports can be exported to other formats very quickly and conveniently by directly using the built-in export button of FineReport. But sometimes we need to customize the exported file type. So how to customize the exported file type?

    You will learn
    • Ideas

    • Implementation steps

      • Template settings

      • Define events

    • Preview

    • Completed template

    II. Ideas

    This can be achieved by adding custom buttons to the Pagination Preview Settings to set JS events.

    III. Implementation steps

    3.1 Template settings

    Let's take the customization of exported txt file as an example.

    Open the template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\GettingStartedEN.cpt

    Click template > Template Web Attributes > Pagination Preview Settings > Setting for Template Separately, as shown below:

    Double-click the Custom button to set the widget alias to “Custom”, as shown below:

     

     

    3.2 Define events

    Click Custom Event to enter the interface of setting callback function

    Add two parameters servletURL and reportName, and insert the formulas for the parameter values: servletURL and reportName, as shown below:

     

    JS code:

    var mrname=FR.cjkEncode(reportName);  /* directory and file name, encoded by fanruan js*/    
    var mrurl=servletURL+'?viewlet='+mrname; /* get the path*/    
    /*window.open(mrurl+'&format=text');*/    
    window.location.href=mrurl+'&format=text';/*download the file*/

    Note: The final exported file type is determined by the content of format=text in the JS code

    The export code is as shown above:

    format=word // Export a file in Word format    
    format=excel //Export a file in Excel format    
    format=pdf //Export a file in Excel format

    IV. Preview

    4.1 PC terminal

    Click the Pagination Preview and click the Custom button on the toolbar to export a txt file, as shown below:

    5.PNG 

    Note: Mobile terminal is not supported.

    V. Completed template

    Attachment List


    Theme: Report Application
    • 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