在IE 11中下载Excel文件

我有这个ExtJS代码,用于将网格数据转换为Excel格式并写入文件,代码将最终将网格数据导出到可下载的Excel文件中。 这在firefox和chrome中效果很好,但在IE浏览器(IE 11)中无法运行。

经分析发现,代码最终会将下面的string张贴到URL下拉框中,该框将下载excel文件。

data:application/vnd.ms-excel;base64,<base64 encoded string follows here> 

起初,我认为问题可能在代码中的某个地方,然后我碰巧检查下面的步骤。 如果我在Chrome或Firefox中粘贴下面的内容,它会提示文件下载并下载一个虚拟文件。

 data:application/vnd.ms-excel;base64,blahblahblahblahblah 

但是,如果我粘贴在IE 11上面的相同的string,它什么都不做。 所以我在假设代码工作正常,但我可能不得不做更多的东西,使其兼容IE浏览器。 但我不知道还有什么我可以尝试。

任何指针深表赞赏。

下面是我的ExtJS代码,如果有帮助。

  //here xmlString has the constructed xml string which holds //grid column headers + grid rows with Table, Column, Cell and Worksheet tags. var ctx = { created : (new Date()).getTime(), worksheets : xmlString }; var uri = 'data:application/vnd.ms-excel;base64,', tmplWorkbookXML = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">' + '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Author>BlahBlah</Author><Created>{created}</Created></DocumentProperties>' + '<Styles>' + '<Style ss:ID="columnHeader"><Font ss:Size="11" ss:Bold="1" /><Interior ss:Color="#CCFFCC" ss:Pattern="Solid"/> </Style>' + '</Styles>' + '{worksheets}</Workbook>', base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); }, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }); }; var workbookXML = format(tmplWorkbookXML, ctx); var link = document.createElement("A"); link.href = uri + base64(workbookXML); link.download = sheetName + " Level Report - " + Ext.Date.format(new Date(), 'Ymd H:i:s') + '.xls'; link.target = '_blank'; document.body.appendChild(link); link.click(); document.body.removeChild(link); 

PS:我已经在ExtJS V4.1和V6.0上试过这个,但是行为相同。