edge浏览器导出execl只能选中.txt格式
因为edge浏览器虽然是用的谷歌的内核,但是本身还是ie浏览器使用ie浏览器导出的方法就可以解决
export function downloadFile(obj, name, suffix) { //obj是字符流 name是文件名,suffix是文件后缀传递的参数可根据个人情况 if (window.navigator.msSaveOrOpenBlob) { // 兼容IE const blob = new Blob([obj]); const fileName = parseTime(new Date()) + ‘-‘ + name + ‘.‘ + suffix navigator.msSaveBlob(blob, fileName); } else { const url = window.URL.createObjectURL(new Blob([obj])) const element = document.createElement(‘a‘) element.style.display = ‘none‘ element.href = url const fileName = parseTime(new Date()) + ‘-‘ + name + ‘.‘ + suffix element.setAttribute(‘download‘, fileName) document.body.appendChild(element) element.click() document.body.removeChild(element) } }
相关推荐
tozeroblog 2020-02-17
往后余生 2020-09-17
CXsilent 2020-09-16
webgm 2020-08-16
Lophole 2020-06-28
sqliang 2020-06-14
xcguoyu 2020-06-13
徐建岗网络管理 2020-06-11
前端开发Kingcean 2020-06-11
cbao 2020-06-10
yezitoo 2020-06-06
bigname 2020-06-04
前端开发Kingcean 2020-05-29
xiaofanguan 2020-05-29
皖林 2020-05-11
wbczyh 2020-05-03
zuihaobushi 2020-04-30