Overview
Problem
The document Direct URL Export provides you with a data export method through the GET request. This document introduces how to export data through the POST request.
Implementation Method
You can export data with the POST request method through the built-in function doHyperlinkByPost in FineReport.
The following table describes the function doHyperlinkByPost.
Method | Parameter | Type of the Returned Value | Description |
doHyperlinkByPost(url,config,tar get,feature) | url (mandatory): specifies a URL or a JSON Hyper-Schema definition. config (optional): specifies a parameter to be passed. target (optional): specifies the position where the hyperlink subpage is opened. feature (optional): specifies the attribute of the position where the hyperlink is opened. | void | Returns a hyperlink. Through this method, the system passes the config parameter through the POST request, displays the result in target, and sets window attributes in feature. |
Example
Template Preparation
Create a general report, add a button widget on the parameter panel, and name the button Export.
Click Event Adding
Select the button widget and add a click event, as shown in the following figure. /
JavaScript codes are as follows:
var url="${servletURL}?viewlet=GettingStartedEN.cpt"
var config = {
Region : "New York",
format:"excel"
}
FR.doHyperlinkByPost(url,config,_blank,"_self")
The value of the format parameter indicates the export method. You can refer to the document Exporting a Report Directly Through a URL.
Effect Display
On PC
Save the template and click Pagination Preview. The preview effect is shown in the following figure.
On Mobile Terminals
Save the template, click Mobile Preview, and copy the link, as shown in the following figure.
Open the mobile browser, paste the link, and click Export. The following figure shows the effect.
The following figure shows the effect of the opened file.
Template Download
You can download the example template Exporting a Report Directly Through a URL (POST Request Method).cpt.