将html表导出到Excel不起作用

时间:2016-03-04 17:33:28

标签: jquery html

$("#export-excel").live('click', function(e) {
    window.open('data:application/vnd.ms-excel,' + $('#table-div').html());
    e.preventDefault();
});

这个代码在导出时一直抓取html标签,所以在excel doc中它出现为<table><tbody> .....

1 个答案:

答案 0 :(得分:1)

You can't just set the content type to Excel format and then expect the code to convert itself to Excel.. You actually have to convert the HTML code to the required formatting of Excel.

Have a look at: How can I export tables to excel from a webpage