繁体   English   中英

JS:数据表打印和导出Excel

[英]JS: datatables printing and exporting excel

你好,我有一个问题,这可能是新手问题

我的网站上现在有一个数据表,我想将其打印或导出到excel文件中,我遇到的问题是标签<tfoot></tfoot>未包含在打印和导出中

这是我的代码:

JS:

<script type="text/javascript" class="init">
$(document).ready(function() {
  $('#example').DataTable( {
    dom: 'Bfrtip',
    buttons: [
      {
        extend: 'print',
        customize: function ( win ) {
          $(win.document.body)
            .css( 'font-size', '10pt' )
            .prepend(
              '<img src="http://datatables.net/media/images/logo-fade.png" style="position:absolute; top:0; left:0;" />'
            );

          $(win.document.body).find( 'table' )
            .addClass( 'compact' )
            .css( 'font-size', 'inherit' );
        }
      }
    ]
  } );
} );

</script>

您可以添加footer: true选项。

// ...
extend: 'print',
footer: true,
// ...

有关更多信息,请在此处查看

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM