How to get customized data while export excel

Tags: #<Tag:0x00007f18a6384e90> #<Tag:0x00007f18a6384d50>

i am using key value dropdown in my table instead of value it is getting key while export. is there any function for customize data for export plugin and how to use.

// Define your Handsontable instance with dropdown settings
var hot = new Handsontable(document.getElementById(‘yourTable’), {
data: yourData, // Your data array
colHeaders: true,
columns: [
// Example column with dropdown settings
{ data: ‘yourColumnName’, type: ‘dropdown’, source: [
{ key: ‘Key1’, label: ‘Label1’ },
{ key: ‘Key2’, label: ‘Label2’ },
{ key: ‘Key3’, label: ‘Label3’ }
]}
// Add more columns as needed
],
});

// Export configuration
var exportPlugin = hot.getPlugin(‘exportFile’);
exportPlugin.downloadFile(‘csv’, {
exportHiddenColumns: true,
exportHiddenRows: true,
columnHeaders: true,
mimeType: ‘text/csv’,
charset: ‘utf-8’,
columnDelimiter: ‘,’,
rowDelimiter: ‘\r\n’,
filename: ‘exported_data.csv’,
customizeData: function (data) {
// Iterate through the data and replace dropdown keys with labels
return data.map(function (row, rowIndex) {
return row.map(function (cell, colIndex) {
var cellMeta = hot.getCellMeta(rowIndex, colIndex);
if (typeof cell === ‘object’ && cellMeta && cellMeta.chosenOptions) {
var dropdownData = cellMeta.chosenOptions.data;
var key = cell.key;
var matchingOption = dropdownData.find(function (option) {
return option.key === key;
});
return matchingOption ? matchingOption.label : cell;
}
return cell;
});
});
},
});

Hi @kranthikumar.reddy32

Key-value dropdown isn’t supported out of the box in Handsontable, so it has to be done as a custom implementation. That means it might not be cooperating well with other plugins, such as exporting the table to CSV, and options for exporting are limited to those that can be found here: https://handsontable.com/docs/javascript-data-grid/export-to-csv/#available-options-in-the-export-configuration