ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
18 lines • 680 B
JavaScript
export const downloadCSV = (csv, filename = 'export') => {
const fakeLink = document.createElement('a');
fakeLink.style.display = 'none';
document.body.appendChild(fakeLink);
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' });
// @ts-ignore
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
// Manage IE11+ & Edge
// @ts-ignore
window.navigator.msSaveOrOpenBlob(blob, `${filename}.csv`);
}
else {
fakeLink.setAttribute('href', URL.createObjectURL(blob));
fakeLink.setAttribute('download', `${filename}.csv`);
fakeLink.click();
}
};
//# sourceMappingURL=downloadCSV.js.map