Exporting Different Reports Based on Parameters

  • Last update:February 26, 2026
  • Overview

    Expected Effect

    In actual business scenarios, you may need to select and download a report from specified reports, and customize the exported file name, as shown in the following figure.

    效果.gif

    Implementation Method

    You can add a dropdown-box widget to the parameter panel, obtain the report storage path, add a button widget, and set a Click event for the button widget to export the report when the button is clicked.

    Example

    Template Parameter Adding

    Create a general report, choose Template > Template Parameter on the menu bar, and add two template parameters: TABLE and NAME.

    2.1 添加模板参数.png

    Widget Adding

    Edit the parameter panel, and click Add All to add both parameters to the parameter panel, as shown in the following figure.

    2.2 添加控件.png

    Widget Setting

    (1) Change the widget value of the LabelTABLE widget to Select a Table:, and for the TABLE widget, set the widget type to Drop-down Box Widget, set Type to Custom in Data Dictionary, set Actual Value to the report path, and set Display Value to the report name. The following figure shows the settings.

    iconNote:
    The report path defaults to the path under reportlets. If the report is not directly saved under reportlets, the full path must be provided, and the \ in the path must be changed to /.

    2.3 控件设置(1.png

    (2) Change the widget value of the LabelNAME widget to Custom Name:, and for the NAME widget, set the widget type to Text Widget so that you can customize the name of the exported file.

    (3) Delete the Query button.

    (4) Drag in a button widget, change Button Name to Export to Excel, and add a Click event for the button widget with the following JavaScript (JS) code:

    var tab = _g().getParameterContainer().getWidgetByName("TABLE").getValue(); 
    var name = _g().getParameterContainer().getWidgetByName("NAME").getValue();  
    var pars = '&format=excel&extype=sheet&__filename__='+name;  
    window.location = "${servletURL}?viewlet=" + (tab+pars);

    The following figure shows the operation steps.

    2.3 控件设置(4.png

    (5) Select the Export to Excel button, duplicate it twice, and rename the new buttons to Export to Word and Export to PDF, respectively. Add a Click event for the button widgets with the above JS code, but replace excel in &format=excel with word and pdf, respectively.

    Effect Preview

    Save the template and click Pagination Preview. The effect is the same as that shown in the Expected Effect section.

    iconNote:

    1. The value of Custom Name cannot be left empty.

    2. The effect cannot be previewed on mobile terminals.

    Template Download

    Download the template by clicking Exporting Different Reports Based on Parameters.cpt.

    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