Man*_*038 6 css pdf jquery datatables
我已经去过这个线程Set Column width when exporting to pdf when using datatables net但它已经快一年了,并没有解决我的问题。我想在以 pdf 格式导出 DataTable 时调整我的列的列宽。我试过这个,但没有任何改变:
$('#table').dataTable({
"dom": '<"top"f>tiB',
paging: false,
fixedHeader: {headerOffset: 45},
buttons: [
{
extend: 'pdfHtml5',
exportOptions: {
columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
},
customize : function(doc) {
doc.styles['td:nth-child(8)'] = {
width: '1000px',
'max-width': '1000px'
}
},
text: 'Export: PDF',
orientation: 'landscape',
pageSize: 'A3',
}]
});
Run Code Online (Sandbox Code Playgroud)
包含 pdfmake.js,我也尝试过width: 1000或"width: 1000"类似的东西。
小智 5
我的表中有八列,这段代码对我来说很好用:
$.extend( true, {}, buttonCommon, {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A0',
customize: function (doc) {
doc.defaultStyle.fontSize = 8; //2, 3, 4,etc
doc.styles.tableHeader.fontSize = 10; //2, 3, 4, etc
doc.content[1].table.widths = [ '2%', '14%', '14%', '14%',
'14%', '14%', '14%', '14%'];
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5422 次 |
| 最近记录: |