如何将html(包含标签和输入标签)数据导出到csv或excel

时间:2015-05-21 14:48:48

标签: jquery

我有一个HTML表格。我想将此导出到csv或excel但我无法导出它。下面是我的HTML和JavaScript。但是它给了我带标签的所有数据。

<table id="tableinfo">
    <head>
        <script>
            $("#btnExport").click(function (e) {
                window.open('data:application/vnd.ms-excel,' + $('#tableinfo').html());
                e.preventDefault();
            });
        </script>
    </head>

    <tr>
        <th>Column1</th>
        <th>Column2</th>
        <th>Column3</th>
        <th>Column4</th>
    </tr>
    <tr>
        <td>1</td>
        <td><input type="text" value="3" /></td>
        <td><input type="text" value="4" /></td>
        <td><input type="text" value="5" /></td>
    </tr>
    <tr>
        <td>2</td>
        <td><input type="text" value="6" /></td>
        <td><input type="text" value="7" /></td>
        <td><input type="text" value="8" /></td>
    </tr>
</table>
<input type="button"  Value="Download" id="btnExport" />

1 个答案:

答案 0 :(得分:0)