Javascript HTML数据表导出到Excel
我们使用了下面的代码,它工作正常,但是我们如何在IE windows弹出窗口中设置另存为类型“Excel”?是否可以使用不同的数据表作为源生成多个excel工作表Javascript HTML数据表导出到Excel,javascript,html,Javascript,Html,我们使用了下面的代码,它工作正常,但是我们如何在IE windows弹出窗口中设置另存为类型“Excel”?是否可以使用不同的数据表作为源生成多个excel工作表 // If Internet Explorer(Not supported Data URIs), Check navigator details & find whether it is IE or NOT if (window.navigator.userAgent.indexOf("MSIE ") > 0
// If Internet Explorer(Not supported Data URIs), Check navigator details & find whether it is IE or NOT
if (window.navigator.userAgent.indexOf("MSIE ") > 0 || !!window.navigator.userAgent.match(/Trident.*rv\:11\./)) {
exportIF.document.open("txt/html", "replace");
exportIF.document.write(document.getElementById('dataTable').innerHTML]);
exportIF.document.close();
exportIF.focus();
//SaveAs command to Save CSV File
sa = exportIF.document.execCommand("SaveAs", true, name + ".xls");
return (sa);
}
else //other browsers : Chrome/FireFox (Supported Data URIs)
{
var bb = new Blob([document.getElementById('dataTable').innerHTML], {
type: "application / vnd.ms - excel"
});
var link = document.createElement("a");
link.download = name + '.xls';;
link.href = window.URL.createObjectURL(bb);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}