有没有人知道如何设置从Buttons扩展程序生成的PDF样式?我特意只是想对齐。我如何在数据表中使用colspan?
谢谢
我的代码是
$('#reporTable').DataTable({
"paging" : false,
"ordering": false,
"info" : false,
"searching" : false,
dom: 'T<"clear">lfrtip',
tableTools: {
"sSwfPath": "/javascripts/js/dataTables/tools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "pdf",
"sTitle": $filename,
"sPdfOrientation": "landscape",
"sPdfMessage": $out_name+":" + msg
},
],
}
});
答案 0 :(得分:4)
以下是它的示例代码。
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [{
extend: 'pdfHtml5',
title: 'My title' + '\n' + 'a new line',
customize: function(doc) {
doc.styles.title = {
color: 'red',
fontSize: '40',
background: 'blue',
alignment: 'center'
}
doc.styles.tableHeader = {
color: 'red',
background: 'blue',
alignment: 'right'
}
doc.styles.tableBodyEven = {
background: 'yellow',
alignment: 'right'
}
doc.styles.tableBodyOdd = {
background: 'blue',
alignment: 'right'
}
doc.styles.tableFooter = {
background: 'blue',
alignment: 'right'
}
doc.styles['td:nth-child(2)'] = {
width: '100px',
'max-width': '100px'
}
}
}]
})