I have recently started using Bootstrap Table and the export plugin for it. A problem I came across is that the export plugin doesn't work for IE, because the files are output using Data URI, which IE doesn't support (I think I read that IE 11 supports it, but no one in my organization uses IE 11, of course.).
The only file types I am interested in exporting are Microsoft office types (Word, Excel) and PDFs.
I have created a functioning workaround for the MS files.
if (supportsDataUriNavigation())
window.open('data:application/vnd.ms-' + defaults.type + ';filename=exportData.doc;' + base64data);
else {
var iframe = document.getElementById("dataFrame");
iframe = iframe.contentWindow || iframe.contentDocument;
iframe.document.open("text/html", "replace");
iframe.document.write(excelFile);
iframe.document.close();
iframe.focus();
iframe.document.execCommand("SaveAs", true, defaults.fileName + fileExtension);
}
In this check, if the browser is IE, then I use the code I found here. This works great for the MS file types, but when I try to do the same for the PDF file, it tries to save as a .htm file. This file is blank. If I replace the fileExtension variable with .pdf in my code, the SaveAs window will not display when I click to export. There are no javascript errors.
I set the src attribute of an embed tag to a string that is returned by the plugin javascript, and it looks like so: 'application/pdf;base64,' + Base64.encode(buffer)
Anyone know of any solution/workaround?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…