How to download an excel file in Safari
Hello JavaScripters,
I'm trying to download a blob file with type xlsx (excel) in Safari. I did this:
obReader = new FileReader();
obReader.onload = function(e) {
obdata = btoa(obReader.result);
obDatauri = 'data:' + isbContentType + ';base64,' + obdata;
window.location = obDatauri;
};
obReader.readAsBinaryString(iobBLOB);
This code above downloads pdf and txt files but when I use to download an excel file it doesn't works.
The var iobBLOB has the blob and isbContentType has the Content-Type, I have been used this ones:
and others seen in here
The Blob files has this type:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Tested on a Macbook pro, Safari 9.03
Note: This code works on ChromeiOS and Safari (iPhone)
Thanks for the help!
链接地址: http://www.djcxy.com/p/8210.html上一篇: 下载Excel无法在iPad中工作
下一篇: 如何在Safari中下载excel文件