export function handerFillZero(num){
return num>=10 ? num : '0'+num;
}
export function exportExcel(vm, params) {
if (vm.choosedResumeIds.length == 0) return;
vm.$http.get(url_exportCsv, {
params: {
resumes: vm.choosedResumeIds.join(','),
response: true,
t:Date.now()
}
}).then((res) => {
// console.log('excel-res:', res);
// console.log('excel-res:',res.request.getAllResponseHeaders());
// console.log("res.headers['content-type']", res.headers['content-type']);
let _file = new Blob([new Uint8Array([0xEF, 0xBB, 0xBF]),res.data], {
type: 'text/plain;charset=utf-8'
}),
_date = new Date(),
_year = _date.getFullYear(),
_month = _date.getMonth()+1,
_day = _date.getDate(),
_hour = _date.getHours(),
_min = _date.getMinutes(),
_sec = _date.getSeconds();
// console.log('_file',_file);
var href = window.URL.createObjectURL(_file);
// console.log('href', href)
var downloadElement = document.createElement('a');
downloadElement.href = href;
downloadElement.download = `导出的List ${_year}-${handerFillZero(_month)}-${handerFillZero(_day)}.csv`; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
ipcRenderer.removeAllListeners('exprot-excel-success');
ipcRenderer.on('exprot-excel-success',(e,params)=>{
if(params.state=='completed'){
vm.$message({
type:'success',
message:'Excel导出成功'
})
vm.clearChoosedIds();
}
})
})
}

导出excel - 自用的更多相关文章

  1. 用NPOI导出Excel,生成下拉列表、以及下拉联动列表(第1篇/共3篇)

    最近帅帅的小毛驴遇到一个很奇葩的需求: 导出Excel报表,而且还要带下拉框,更奇葩的是,下拉框还是联动的. 小毛驴一天比较忙,所以这等小事自然由我来为她分忧了.经历了两天,做了几种解决方案,最后完美 ...

  2. 由需求而产生的一款db导出excel的工具

    代码地址如下:http://www.demodashi.com/demo/12062.html 程序员最大的毛病可能就是懒,因为懒所以做出了许许多多提高自己工作效率的工具. 起因于我是商业开发,既然是 ...

  3. C#使用Aspose.Cells导出Excel简单实现

    首先,需要添加引用Aspose.Cells.dll,官网下载地址:http://downloads.aspose.com/cells/net 将DataTable导出Xlsx格式的文件下载(网页输出) ...

  4. 利用poi导出Excel

    import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.r ...

  5. [django]数据导出excel升级强化版(很强大!)

    不多说了,原理采用xlwt导出excel文件,所谓的强化版指的是实现在网页上选择一定条件导出对应的数据 之前我的博文出过这类文章,但只是实现导出数据,这次左思右想,再加上网上的搜索,终于找出方法实现条 ...

  6. NPOI导出Excel

    using System;using System.Collections.Generic;using System.Linq;using System.Text;#region NPOIusing ...

  7. ASP.NET Core 导入导出Excel xlsx 文件

    ASP.NET Core 使用EPPlus.Core导入导出Excel xlsx 文件,EPPlus.Core支持Excel 2007/2010 xlsx文件导入导出,可以运行在Windows, Li ...

  8. asp.net DataTable导出Excel 自定义列名

    1.添加引用NPOI.dll 2.cs文件头部添加 using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using System.IO; 3.代码如 ...

  9. Aspose.Cells导出Excel(1)

    利用Aspose.Cells导出excel 注意的问题 1.DataTable的处理 2.进行编码,便于中文名文件下载 3.别忘了Aspose.Cells.dll(可以自己在网上搜索) public ...

随机推荐

  1. setings.py配置文件详解

    BASE_DIR指的是项目的根目录.SECRET_KEY是安全码. # SECURITY WARNING: don't run with debug turned on in production! ...

  2. centos6.4 ssh免密码登陆(只需三个步骤)

    学习Hadoop的时候,用到的.这里作为记录. 以下是最简洁的方式: 4台虚拟机: 用户:root.hadoop hostname 分别是:Master.Hadoop.Slave1.Hadoop.Sl ...

  3. ACM_Ruin of Titanic(简单贪心)

    Ruin of Titanic Time Limit: 2000/1000ms (Java/Others) Problem Description: 看完Titanic后,小G做了一个梦.梦见当泰坦尼 ...

  4. UNIX环境高级编程--1

    前期准备: 下载apue3源文件(从apuebook.com上),然后编译(make)之后,得到libapue.a动态链接文件(.o 就相当于windows里的obj文件 .a 是好多个.o合在一起, ...

  5. CF831C Jury Marks

    思路: 关键在于“插入”一个得分之后,其他所有得分也随之确定了. 实现: #include <iostream> #include <cstdio> #include < ...

  6. unity 旋转两种方法

    transform.Rotate(new Vector3(0, 10, 10)*speed*Time.deltaTime); // 物体绕x轴.y轴.z轴旋转 transform.RotateArou ...

  7. HDU_1068_Girls and Boys_二分图匹配

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. 大神所写的深度好文---Gradle 构建工具

    什么是构建工具? 我们大家都知道 Gradle 是一种构建工具,那么什么是构建工具呢? 网上一大堆的文字解释我觉得很难理解,这里我以咱们 Android 开发来举个例子吧. 我们以前开发都是用 Ecl ...

  9. bat配置JDK环境变量

    最近总是部署服务器,总是要安装配置JDK,今天就想写个bat来配置JDK的环境变量,首先介绍点bat的小知识 @符号后面的命令不会显示在terminal上 例如: @echo运行时 隐藏命令(不在te ...

  10. Origin C调用GSL

    GSL (GNU Scientific Library, http://www.gnu.org/software/gsl/)是C.C++的数值算法库,提供了范围宽广的数学程序,包括随机数字生成器.数理 ...