一、HTML代码

<el-col :xs="2" :md="2" :sm="3">
<el-button type="primary" style="width:100%;" @click.stop="handleDownloadExecl">导 出</el-button>
</el-col>

二、JS代码

// 根据查询条件下载excel
handleDownloadExecl () {
downloadDisabilityListExcelApi(this.searchForm).then(info => {
if (!info) {
return
}
let url = window.URL.createObjectURL(info)
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('id', 'downloadLink')
link.setAttribute('download', '残疾人信息表.xls')
document.body.appendChild(link)
link.click()
// 删除添加的a链接
let objLink = document.getElementById('downloadLink')
document.body.removeChild(objLink)
// 释放内存
window.URL.revokeOjbectURL(url)
})
}

三、axios的设置

export function downloadDisabilityListExcelApi (data) {
return service({
url: `/excel/excelDownloads`,
method: 'GET',
params: data,
responseType: 'blob'
})
}

后端根据查询条件生成excel文件返回给前端,vue进行下载的更多相关文章

  1. java实现点击查询数据生成excel文件并下载

    须先导入关键maven包 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi& ...

  2. 如何生成excel文件作为图像识别结果

    如何生成excel文件作为图像识别结果 在进行大规模图像处理的时候,如果能够以表格的形式生成结果文件,将非常的直观.这个时候,选择excel作为结果输出文件,将是合适的. 查询相关资料,有很多关于ex ...

  3. 实现excel导入导出功能,excel导入数据到页面中,页面数据导出生成excel文件

    今天接到项目中的一个功能,要实现excel的导入,导出功能.这个看起来思路比较清楚,但是做起了就遇到了不少问题. 不过核心的问题,大家也不会遇到了.每个项目前台页面,以及数据填充方式都不一样,不过大多 ...

  4. POI生成EXCEL文件

    POI生成EXCEL文件 一.背景 根据指定格式的JSON文件生成对应的excel文件,需求如下 支持多sheet 支持单元格合并 支持插入图片 支持单元格样式可定制 需要 标题(title),表头( ...

  5. python xlwt模块生成excel文件并写入数据 xlrd读取数据

    python中一般使用 xlwt (excel write)来生成Excel文件(可以控制单元格格式),用 xlrd 来读取Excel文件,用xlrd读取excel是不能对其进行操作的. 1.xlrd ...

  6. 使用python在WEB页面上生成EXCEL文件

    来自:http://blog.sina.com.cn/s/blog_5d18f85f0101bxo7.html 近日写的一个程序需要在WEB服务器上生成EXCEL文件供用户下载,研究了一下找到了以下比 ...

  7. php生成excel文件的简单方法

    生成excel文件,最简单的莫过于把数据库的数据导入到excel就行了. 生成excel 当然使用的是 phpExcel http://www.jbxue.com/tags/phpexcel.html ...

  8. XLSTransformer生成excel文件简单演示样例

    项目结构图: 项目中所用到的jar,能够到http://www.findjar.com/index.x下载 ExcelUtil类源代码: package util; import java.io.IO ...

  9. XLSTransformer生成excel文件

    jxls的使用方法: 1)声明一个XLSTransformer对象,生成方式就是使用new操作符                 XLSTransformer transformer = new XL ...

随机推荐

  1. 第五章 Flask视图高级

    add_url_rule和app.route原理剖析 add_url_rule add_url_rule(rule,endpoint=None,view_func=None) 这个方法用来添加url与 ...

  2. django加载本地html

    django加载本地html from django.shortcuts import render from django.http import HttpResponse from django. ...

  3. JQuery实践--插件

    jQuery插件的概览http://docs.jquery.com/Pluginshttp://jquery.com/plugins/most_popular 官方的表单插件http://jquery ...

  4. 运算符重载之new与delete

    关于new/delete,援引C++ Primer中的一段话: 某些应用程序对内存分配有特殊的要求,因此我们无法直接将标准的内存管理机制直接应用于这些程序.他们常常需要自定义内存分配的细节,比如使用关 ...

  5. pwrite,pread

    pwrite,pread,在多线程中读写文件使用,将lseek 和read 或write 合为一个原子操作(在执行的时候不会失去CPU). ssize_t pwrite(intfd, const vo ...

  6. bzoj3508: 开灯

    题目链接 题解 设\(b[i]=a[i]\ xor\ a[i+1]\) 我们可以发现,修改只会改变\(b[l-1]\)和\(b[r]\) 然后发现\(b[i]=1\)的点最多\(2*k\)个 状压\( ...

  7. idea 启动 Error running 'XxGatewayApplication': Command line is too long. Shorten command line for XxGatewayApplication or also for Spring Boot default

    在idea workspace里 <component name="PropertiesComponent">标签下加入 <property name=" ...

  8. 【线性代数】6-5:正定矩阵(Positive Definite Matrices)

    title: [线性代数]6-5:正定矩阵(Positive Definite Matrices) categories: Mathematic Linear Algebra keywords: Po ...

  9. VMWare Fusion 8 序列号

    FY75A-06W1M-H85PZ-0XP7T-MZ8E8 ZY7TK-A3D4N-08EUZ-TQN5E-XG2TF FG1MA-25Y1J-H857P-6MZZE-YZAZ6

  10. Simple Problem with Integers(POJ 3486)

                                                                  A Simple Problem with Integers Time Li ...