You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I change data filename of the exported data? I can't seem to get around it. This is my export function, I want it to have a custom name since its default is either ''data" or "all-data"
function getExportFileBlob({ columns, data, fileType, fileName }) {
if (fileType === 'xlsx') {
// XLSX example
const header = columns.map(c => c.exportValue);
const compatibleData = data.map(row => {
const obj = {};
header.forEach((col, index) => {
obj[col] = row[index];
});
return obj;
});
let wb = XLSX.utils.book_new();
let ws1 = XLSX.utils.json_to_sheet(compatibleData, {
header,
});
XLSX.utils.book_append_sheet(wb, ws1, 'React Table Data');
XLSX.writeFile(wb, `${fileName}.xlsx`);
// Returning false as downloading of file is already taken care of
return false;
}
}
I call this on my tableInstance and the button that I use to export is below
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How do I change data filename of the exported data? I can't seem to get around it. This is my export function, I want it to have a custom name since its default is either ''data" or "all-data"
I call this on my tableInstance and the button that I use to export is below
Beta Was this translation helpful? Give feedback.
All reactions