简体   繁体   English

jQuery Excel导出在IE9中不起作用

[英]Jquery excel export is not working in IE9

I want to download my HTML table as Excel. 我想将HTML表格下载为Excel。 For that I used the given code 为此,我使用了给定的代码

$('#export').click(function (e) {
   var dt = new Date();
   var day = dt.getDate();
   var month = dt.getMonth() + 1;
   var year = dt.getFullYear();
   var hour = dt.getHours();
   var mins = dt.getMinutes();
   var postfix = day + "." + month + "." + year + "_" + hour + "." + mins;
   var a = document.createElement('a');
   var data_type = 'data:application/vnd.ms-excel';
   var table_div = document.getElementById('reportDiv');
   var table_html = table_div.outerHTML.replace(/ /g, '%20');
   a.href = data_type + ', ' + table_html;
   a.download = 'UserMatrix' + postfix + '.xls';
   a.click();
   e.preventDefault();
});

It's working in Chrome and Firefox but not working in Internet Explorer 9. 它可以在Chrome和Firefox中运行,但不能在Internet Explorer 9中运行。

You'd need to use an alternate solution for IE9 as it doesn't support the HTML download attribute for the anchor tag. 您需要为IE9使用替代解决方案,因为它不支持锚标记的HTML download属性。

Here's a popular Javascript option: https://github.com/dcneiner/Downloadify 这是一个流行的Javascript选项: https : //github.com/dcneiner/Downloadify

It uses Flash, though, which IE 9 would support. 不过,它使用Flash,这是IE 9会支持的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM