j.f*_*ong 5 javascript jquery datatables
我正在使用Buttons扩展在jQuery DataTables上实现导出按钮.我将所有按钮都工作,除了导出到Excel按钮.
包括以下所有脚本:
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/datatables/media/js/jquery.dataTables.js"></script>
<script src="bower_components/datatables/media/js/dataTables.bootstrap.js"></script>
<script src="bower_components/datatables-buttons/js/dataTables.buttons.js"></script>
<script src="bower_components/datatables-buttons/js/buttons.html5.js"></script>
<script src="bower_components/datatables-buttons/js/buttons.print.js"></script>
<script src="bower_components/datatables-buttons/js/buttons.bootstrap.js"></script>
<script src="bower_components/jszip/dist/jszip.js"></script>
<script src="bower_components/pdfmake/build/pdfmake.js"></script>
<script src="bower_components/pdfmake/build/vfs_fonts.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后我创建按钮并将它们附加到div:
// Create and render buttons
new $.fn.dataTable.Buttons( table, {
buttons: ['copyHtml5', 'csvHtml5', 'excelHtml5', 'pdfHtml5', 'print']
})
table.buttons().container().appendTo($('.header-right'), self);
Run Code Online (Sandbox Code Playgroud)
单击Excel按钮时,我的应用程序会下载xlsx.zip文件.为什么不下载".xlsx"文件?
我也尝试通过手动添加扩展来扩展按钮,但是我设置的扩展属性最终为"extension-name.zip".
new $.fn.dataTable.Buttons( table, {
buttons: [
{
extend: 'excelHtml5',
extension: '.xlsx'
}
]
})
Run Code Online (Sandbox Code Playgroud)
小智 8
设置Title属性对我有用.
以下.xlsx文件扩展名导出
buttons: [{
extend: 'excelHtml5',
title: 'Location Report'
}
],.....etc
Run Code Online (Sandbox Code Playgroud)
未设置标题时,文件以.zip文件扩展名导出
buttons: [{
extend: 'excelHtml5',
title: ''
}
],.....etc
Run Code Online (Sandbox Code Playgroud)
我也有同样的问题....但我认为它与浏览器有关.
| 归档时间: |
|
| 查看次数: |
3775 次 |
| 最近记录: |