标签:fun win coder nbsp lob cti hoc turn bin
后台java (jdk>=1.8):
byte[] bytes = byteArrayOutputStream.toByteArray();
String base64Str = java.util.Base64.getEncoder().encodeToString(bytes);
前端:
function dataURLtoBlob(base64Str) {
var bstr = atob(base64Str), n = bstr.length, u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], { type: "application/vnd.ms-excel" }); //该类型为xls
}
var blob = dataURLtoBlob(base64Str);
var downloadUrl = window.URL.createObjectURL(blob);
var anchor = document.createElement("a");
anchor.href = downloadUrl;
anchor.download = "aa.xls";
anchor.click();
window.URL.revokeObjectURL(blob);
其他类型:
标签:fun win coder nbsp lob cti hoc turn bin
原文地址:https://www.cnblogs.com/shihx/p/12578636.html