美文网首页JS
JS 导出table标签为excel

JS 导出table标签为excel

作者: 五岁小孩 | 来源:发表于2020-07-25 22:20 被阅读0次

    js导出table标签为excel

    • 添加依赖

      html底部添加依赖

       <script src="/jquery-table2excel/dist/jquery.table2excel.min.js
                    ">
      </script>
      
    • js使用

      调用以下方法即可,其中.table 为table标签的class

      //导出
      function exportData() {
          $(".table").table2excel({
              // 不被导出的表格行的CSS class类
              exclude: ".noExl",
              // 导出的Excel文档的名称
              name: "fund-" + new Date().getTime(),
              // Excel文件的名称
              filename: "fund-" + new Date().getTime() + ".xls",
              bootstrap: true,
              preserveColors: true 
              // set to true if you want background colors and font
              //colors preserved
          });
      }
      

    相关文章

      网友评论

        本文标题:JS 导出table标签为excel

        本文链接:https://www.haomeiwen.com/subject/yvhvlktx.html