2021-08-16 13:12:07 +02:00
|
|
|
export const saveUrl = ({ document }: Window, url: string, filename: string) => {
|
2021-03-14 11:47:23 +01:00
|
|
|
const link = document.createElement('a');
|
|
|
|
|
|
|
|
link.setAttribute('href', url);
|
|
|
|
link.setAttribute('download', filename);
|
|
|
|
link.style.visibility = 'hidden';
|
|
|
|
document.body.appendChild(link);
|
|
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
|
|
};
|
2021-08-16 13:12:07 +02:00
|
|
|
|
|
|
|
export const saveCsv = (window: Window, csv: string, filename: string) => {
|
2022-03-26 12:17:42 +01:00
|
|
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
2021-08-16 13:12:07 +02:00
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
saveUrl(window, url, filename);
|
|
|
|
};
|