Export to excel based on the filters selected.

I need to add a script on the button that will help me download excel based on the filter values selected.

I used the below script but still, I am getting all data instead of filtered one. Can anyone help me out with this? How can achieve this?

var excelOptions =
{
appendDateToFileName: false,
overrideFileName: false,
openOnCompletion: true,
enableOverlay: false,
selection: dundas.export.ExportSelection.MULTIPLE_ITEMS,
includeParameterValues: true,
adapterIds: “93de4ef2-2538-cd19-492b-21ff9bf20fef”
};

dundas.export.ExportHelper.exportExcel(excelOptions);

Hi Anupam,

I found this somewhere and hope it helps you for exporting data to excel based on filter values selected. Make sure to change this part to whatever the script name is for your table/visual you are exporting data from. parameterValue.values = [ ExportTable.id ];

// Get the export service.
var exportService = this.getService(‘ExportService’);

// Get the view service.
var viewService = this.getService(‘ViewService’);

// Create the export request.
var exportRequest =
new dundas.export.ExportRequest(
{
isLegacyExport: true,
// Export Excel
providerId: dundas.constants.STANDARD_EXCEL_EXPORT_PROVIDER_ID,
viewData: this.getService(“CanvasService”).canvas.viewModel.businessObject.control
});

// Create parameter value to pass to the request.

var parameterValue = new dundas.data.CollectionStringValue();
parameterValue.parameterId = dundas.constants.EXCEL_ADAPTERS_ID;
parameterValue.values = [ ExportTable.id ];
exportRequest.parameterValues.push(parameterValue);

//Multiple select

var parameterValue = new dundas.data.SingleNumberValue();
parameterValue.parameterId = dundas.constants.EXCEL_EXPORT_SELECTION_ID;
parameterValue.value = 3 ;
exportRequest.parameterValues.push(parameterValue);

//Include parameters

var parameterValue = new dundas.data.SingleBooleanValue;
parameterValue.parameterId = dundas.constants.EXCEL_INCLUDE_PARAMETERS_ID;
parameterValue.value = true;
exportRequest.parameterValues.push(parameterValue);

//On the left

var parameterValue = new dundas.data.SingleNumberValue();
parameterValue.parameterId = dundas.constants.EXCEL_PARAMETER_VALUES_LOCATION_ID;
parameterValue.value = 2;
exportRequest.parameterValues.push(parameterValue);

//Append date to file name

var parameterValue = new dundas.data.SingleBooleanValue;
parameterValue.parameterId = dundas.constants.APPEND_DATE_TO_FILE_NAME_ID;
parameterValue.value = true;
exportRequest.parameterValues.push(parameterValue);

// Get the perform export promise.
var exportPromise =
exportService.performExport(exportRequest);

// Setup a loading dialog.
viewService.showLoadingRestCall(exportPromise);

exportPromise.done(
function(exportId)
{
// Get the Url for the export file.
var exportFileUrl =
exportService.getExportResultUrl(exportId);

  	// Force the browser to download the file.

  window.location.replace(exportFileUrl);
}

);

Solved via email. The sample scripts provided in export articles should simply work in this case because export functionality exports what is seen in the UI.