filedownload(filecontent,filename){
var bytes=window.atob(filecontent);
var ab = new ArrayBuffer(bytes.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < bytes.length; i++) {
ia[i] = bytes.charCodeAt(i);
}
var blob = new Blob( [ab] , {type : "application/octet-stream"});
if(window.navigator.msSaveBlob){
//IE 对a标签下载不支持。微软有自己的下载方法msSaveBlob()。
try{
window.navigator.msSaveBlob(blob, filename);
}
catch(e){
console.log(e);
}
}else{
var url = URL.createObjectURL(blob);
var a = document.createElement("a");
document.body.appendChild(a);
a.style.display = "none";
a.target = "_blank";
a.href = url;
a.download = filename;
a.target= "_blank";
a.click();
}
}
WebApi使用EPPlus导出excelStep1当然是在Nuget下载EPPPlus,然后引入: using OfficeOpenXml; Step2直接上代码吧,使用EPPlus 然后是controller调用...