Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML数据表导出到Excel_Javascript_Html - Fatal编程技术网

Javascript HTML数据表导出到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

我们使用了下面的代码,它工作正常,但是我们如何在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 || !!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);
}