Vue+Springboot,通过EasyExcel工具实现Excel导出

1.前端Vue

(注意:调用后端接口时需指定{responseType:'blob'},否则导出的excel表格打不开)

//Vue导出方法 
exportExcel(){
            //searchParam:为前端需传到后端的所需参数
            var searchParam =  {
                test:this.data.test,


                };
           //调用后端接口,传入参数searchParam
           //注意:调用后端接口时需指定{responseType:'blob'},否则导出的excel表格打不开
            request.post("/exceltest/exportExcel",searchParam,{responseType:'blob'}).then((res) => {
                const aLink = document.createElement('a')
                //为Blob指定导出的文件类型,此处为xlsx[{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}]
                var blob = new Blob([res.data], {type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})
                // //从response的headers中获取filename, 后端response.setH
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值