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 對(duì)a標(biāo)簽下載不支持屯碴。微軟有自己的下載方法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導(dǎo)出excelStep1當(dāng)然是在Nuget下載EPPPlus姆钉,然后引入: using OfficeOpenXml; Step2直接上代碼吧签餐,使用EPPlus 然后是controller調(diào)用...