javascript - JS : datatables printing and exporting excel

标签 javascript printing datatables export

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

我的网站中有一个数据表,现在我想将其打印或导出到 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,
// ...

欲了解更多信息,请查看here .

关于javascript - JS : datatables printing and exporting excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53236969/

相关文章:

java - 如何在指定的打印机上打印Jasper Reports?

python - GDB打印STL数据

r - 有没有办法使用 Shiny 更新的 DT::renderDataTable 和 DT::dataTableOutput 按列搜索?

javascript - 使用 NodeJS 在 mysql 中插入关系表的最佳方法是什么

ios - 在 ios 中自定义打印尺寸

javascript - 如何在 JavaScript 中动态更改 jQuery dataTable 页码?

jquery - 获取具有属性 "bVisible: false"的数据表列的值

javascript - 将 Knockout.JS View 模型绑定(bind)到 jQuery 对话框

javascript - 使用适用于 IE 的 Ajax 进行文件发布

javascript - 每 5 秒自动刷新一个 DIV 代码不工作