使用jquery将列表导出为ex​​cel

时间:2015-03-16 13:45:39

标签: javascript jquery export export-to-excel

我尝试将动态列表导出到excel / notepad / notepad ++ / word。 我看到了将表导出到excel的方法,但这并没有解决我的问题。 我的无序列表包含多个列表(可更改),我要导出的值是类型text(value_to_export)的输入值。 如何导出所有这些列表值? 谢谢?

<ul>
<li id="0" class="list">
<input type="checkbox" class="" id="" value="">
<input type="text" id="" title="" class="" value="value_to_export">
</li>
</ul>

1 个答案:

答案 0 :(得分:0)

您可以使用HTML表格代替li。

table2excel是一个简单但有用的jQuery插件,允许将Html表数据导出到Excel文件。

&#13;
&#13;
< script src = "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" > < /script>
<script src="src/jquery.table2excel.js "></script>
&#13;
&#13;
&#13;

  1. 创建&#39;导出&#39;用于手动将表数据导出到Excel文件的按钮。可选的。
  2. &#13;
    &#13;
    <button>Export</button>
    &#13;
    &#13;
    &#13;

    1. 调用桌面上的插件并完成。
    2. &#13;
      &#13;
      $("button").click(function(){
        $("#table2excel").table2excel({
          // exclude CSS class
          exclude: ".noExl",
          name: "Excel Document Name"
        }); 
      });
      &#13;
      &#13;
      &#13;

      1. 您可以添加CSS类&#39; noExl&#39;导出时忽略指定表数据的任何tr标记。
      2. &#13;
        &#13;
        <tr class="noExl">
          <th>#</th>
          <th>Column heading</th>
          <th>Column heading</th>
          <th>Column heading</th>
        </tr>
        &#13;
        &#13;
        &#13;