前端处理blob数据流
// 获取文件名
const fileName = res.headers['content-disposition'].substring(
res.headers['content-disposition'].indexOf('=') + 1
)
const blob = new Blob([res.data], { type: 'application/x-xls' })
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName)
} else {
// 下载
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
window.URL.revokeObjectURL(link.href)
}
导出excel有两种格式:
.xls--------------application/vnd.ms-excel
.xlsx------------application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
原文地址:https://blog.csdn.net/m0_52872381/article/details/144063166
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!