export function download(file, name) {
let blob;
if (file.data instanceof Blob) {
blob = file.data;
} else {
blob = new Blob([file.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' });
}
const headerDisposition = (file.headers['Content-Disposition'] || '').match(/filename=(.*\.(xlsx|docx))/);
const filename = headerDisposition ? headerDisposition[1] : name;
const url = window.URL.createObjectURL(blob);
if ('msSaveOrOpenBlob' in navigator) {
window.navigator.msSaveOrOpenBlob(blob, filename);
} else {
const eleLink = document.createElement('a');
eleLink.download = filename;
eleLink.style.display = 'none';
eleLink.href = url;
document.body.appendChild(eleLink);
eleLink.click();
document.body.removeChild(eleLink);
}
}