table2excel排除不起作用

时间:2017-05-02 10:55:04

标签: jquery jqgrid

$("td:hidden").addClass("noExl");

$("#estTbl").table2excel({
   exclude: ".noExl",
   name: "file1",
   filename: projectCode+'-'+ startDate+' to'+ endDate ,
   fileext: ".xls",
   exclude_img: true,
   exclude_links: true,
   exclude_inputs: true
});

这并不排除隐藏的TD。我怎样才能添加" noExl"手动隐藏TD。

1 个答案:

答案 0 :(得分:0)

您可以隐藏单个td,但在这种情况下,下一个td将移动到之前隐藏的地方,请参阅下面的代码段,



jQuery(document).ready(function() {
    $('#export-btn').on('click', function(e){
        $("#estTbl").table2excel({
            exclude: ".noExl",
            name: "Data",
            filename: "tblExport.xlsx",
        });
    });
});

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.rawgit.com/rainabba/jquery-table2excel/1.1.0/dist/jquery.table2excel.min.js"></script>
<button id="export-btn">Export</button>
<table id="estTbl">
  <thead>
    <tr class="noExl">
      <td>This shouldn't get exported</td>
      <td>This shouldn't get exported either</td>
    </tr>
    <tr>
      <td>This Should get exported as a header</td>
      <td>This should too</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="noExl">This too data1a</td>
      <td>data1b</td>
    </tr>
    <tr>
      <td>data2a</td>
      <td>data2b</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">This footer spans 2 cells</td>
    </tr>
  </tfoot>
</table>
&#13;
&#13;
&#13;