首页 新闻 会员 周边

使用FileSaver导出时,导出的文件没有后缀名这是为什么

0
悬赏园豆:20 [已解决问题] 解决于 2020-05-06 13:49

var json = spread.toJSON({ includeBindingSource: true });

        // here is excel IO API
        me.excelIo.save(json, function (blob) {
            saveAs(blob, "111.xlsx");
        }, function (e) {
            // process error
            console.log(e);
        }, { password: password });

saveAs(blob, "111.xlsx");已经给予了后缀名,但导出的时候并没有按照这个(111.xlsx)名称来导出,这是为什么

但乱红尘熊的主页 但乱红尘熊 | 小虾三级 | 园豆:773
提问于:2020-04-11 13:07
< >
分享
最佳答案
0

excelIo.save(json, function (blob) {
//saveAs(blob, "111.xlsx");

            //解决浏览器兼容性问题
            var objectUrl = window.URL.createObjectURL(blob);
            var a = document.getElementById('downList');
            a.href = objectUrl;
            a.download = fileName;
            a.click();
        }, function (e) {
            // process error
            console.log(e);
        }, { password: password });原因是浏览器兼容问题,在360和谷歌上不好用,添加以上代码后,可以下载成功,不过用wps打开可以,excel会有安全提示弹框
但乱红尘熊 | 小虾三级 |园豆:773 | 2020-05-06 13:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册