Overview
Expected Effect
In actual business scenarios, you may want to filter data from the current table and export filtered data into multiple files separately, as shown in the following figure.

Implementation Method
You can add a button widget to the parameter panel, configure a click event for it, obtain the selected parameters in the drop-down checkbox widget, and click the button to batch export the current table.
Example
Data Preparation
Create a general report and create a data query named ds1 with the SQL statement:
SELECT * FROM Inventory
where 1=1 ${if(len(Warehouse) == 0,"","and Warehouse in ('" + Warehouse + "')")}
where 1=1 means that the condition is always true, preventing errors caused by the absence of valid content after the WHERE clause when no parameter condition exists.
len(warehouse)==0 indicates that the parameter Warehouse is empty.
Warehouse in and Warehouse in ('" + warehouse + "') represents the obtained parameter value, and + is the string concatenation symbol.
The query statements:
If the value of the parameter Warehouse is empty, the query statement is SELECT * FROM Inventory.
If the value of the parameter Warehouse is not empty, the query statement is SELECT * FROM Inventory WHERE 1=1 and Warehouse in ('${Warehouse}').

On the designer menu bar, choose Template > Template Parameter. Create template parameters Opening and Closing, and left the default values empty, as shown in the following figure.

Report Design
Design the report, as shown in the following figure.

Note: You need to add a filter condition for the A5 cell where the warehouse data column is located, to display data based on parameters. Conditions should be connected with and, as shown in the following figure.

Widget Setting
(1) Enter the parameter panel and add all parameters to the parameter panel.

(2) Set the Opening and Closing parameter widgets to Date widgets and set the default values, respectively.

(3) Set the Warehouse parameter widget to a Drop-down Checkbox widget, set Database Table in Data Dictionary to the Inventory table in the FRDemo database for the widget, and set both Actual Value and Display Value to Warehouse. Select Returned Value's Type to String and manually enter "," for Separator.

(4) Change the query button name to Generate Inventory Ledger.
(5) Drag a Button widget to the panel and rename it to Batch Export. Adjust the widget positions, and the final effect is as shown in the following figure.

Click Event Adding
Select the Batch Export button, and add a Click event with the following JavaScript code:
Note:function ForTime(oldTime) {
Date.prototype.format = function(fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
}
var oldTime = (new Date(oldTime)).getTime();
var curTime = new Date(oldTime).format("yyyy-MM-dd");
return curTime;
}
var url = 'Exporting Multiple Files in Batches Based on Parameters.cpt';
var name = _g().getParameterContainer().getWidgetByName("Warehouse").getValue();
var qc = _g().getParameterContainer().getWidgetByName("Opening").getValue();
var qm = _g().getParameterContainer().getWidgetByName("Closing").getValue();
var arr = name.split("','");
for (var i = 0; i < arr.length; i++) {
var pars = '&format=excel&extype=sheet&__filename__=' + arr[i];
window.open("${servletURL}?viewlet=" + encodeURI(url + pars) + "&Warehouse=" + encodeURI(arr[i]) + "&Opening=" + encodeURI(ForTime(qc)) + "&Closing=" + encodeURI(ForTime(qm)), "_blank");
}

Effect Preview
Save the report. To avoid pagination, click Data Analysis Preview, and the effect is the same as that in the "Expected Effect" section.
Note:2. Internet Explorer is not supported. The effect cannot be previewed on mobile terminals.
Template Download
Download the template by clicking Exporting Multiple Files in Batches Based on Parameters.cpt.