I have written below code to download file. It is working for the limited record. now my record count is more that 12000. Then it is hanging the browser and file not downloaded
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var edgetype = ua.indexOf("Edge");
var blobObject;
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
expExcelIframe.document.open("txt/html", "replace");
expExcelIframe.document.write(html);
expExcelIframe.document.close();
expExcelIframe.focus();
expExcelIframe.document.execCommand("SaveAs", true, fileName);
}
else if (edgetype > 0) {
blobObject = new Blob([html]);
window.navigator.msSaveOrOpenBlob(blobObject, fileName);
}
else {
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
}
Replace encodeURIComponent
:
SLOW
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
var blob = new Blob([html],{type: 'data:application/vnd.ms-excel' });
var u = URL.createObjectURL(blob);
window.open(u);
This avoids the memory and computation intensive step of converting to base64.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.