js可选表格择字段导出excel

js可选表格择字段导出excel

纯前端实现可选字段导出。
插件链接:js可选表格择字段导出excel

如果想要后端获取数据在可选字段导出,只需要把要导出的字段传给后端,后端直接生成一个excel文件,前端下载文件就行,下载代码如下:

// xlsx下载
download(fileName, fileData) {
    if(this.isIosOrAndroid() == 1){
        let a = document.createElement('a'); //创建a标签
        a.setAttribute('href', fileData);
        a.setAttribute('download', fileName);
        a.setAttribute('target', '_blank'); //打开一个新的窗口
        a.setAttribute('id', "downLoad");
        if (document.getElementById('downLoad')) {
            document.body.removeChild(document.getElementById('downLoad'));
        }
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
    }else{
        window.location.href = fileData
    }
},
暂无评论

发送评论 编辑评论


				
上一篇
下一篇