diff --git a/frontend/src/Editor/Components/Table/Table.jsx b/frontend/src/Editor/Components/Table/Table.jsx index 1a80472b3b..ca7e1f3adf 100644 --- a/frontend/src/Editor/Components/Table/Table.jsx +++ b/frontend/src/Editor/Components/Table/Table.jsx @@ -195,14 +195,22 @@ export function Table({ } function getExportFileBlob({ columns, fileType, fileName }) { - let headers = columns.map((col) => String(col.exportValue)); + let headers = columns.map((column) => { + return { exportValue: String(column.exportValue), key: column.key ? String(column.key) : column.key }; + }); const data = globalFilteredRows.map((row) => { - return headers.reduce((acc, header) => { - acc[header.toUpperCase()] = row.original[header]; - return acc; + return headers.reduce((accumulator, header) => { + let value = undefined; + if (header.key && header.key !== header.exportValue) { + value = row.original[header.key]; + } else { + value = row.original[header.exportValue]; + } + accumulator[header.exportValue.toUpperCase()] = value; + return accumulator; }, {}); }); - headers = headers.map((header) => header.toUpperCase()); + headers = headers.map((header) => header.exportValue.toUpperCase()); if (fileType === 'csv') { const csvString = Papa.unparse({ fields: headers, data }); return new Blob([csvString], { type: 'text/csv' }); @@ -338,7 +346,6 @@ export function Table({ darkMode, ] // Hack: need to fix ); - const data = useMemo( () => tableData, [ diff --git a/frontend/src/Editor/Components/Table/columns/index.jsx b/frontend/src/Editor/Components/Table/columns/index.jsx index 6645b4c33e..85f4fcd067 100644 --- a/frontend/src/Editor/Components/Table/columns/index.jsx +++ b/frontend/src/Editor/Components/Table/columns/index.jsx @@ -66,6 +66,7 @@ export default function generateColumnsData({ cellBackgroundColor: column.cellBackgroundColor, columnType, isEditable: column.isEditable, + key: column.key, Cell: function (cell) { const rowChangeSet = changeSet ? changeSet[cell.row.index] : null; let cellValue = rowChangeSet ? rowChangeSet[column.name] || cell.value : cell.value;