Reputation: 449
$('#example').dataTable({ dom: 'Bfrtip', buttons: [ { extend: 'excelHtml5', title: 'Excel', text:'Export to excel' //Columns to export //exportOptions: { // columns: [0, 1, 2, 3,4,5,6] // } }, { extend: 'pdfHtml5', title: 'PDF', text: 'Export to PDF', //Columns to export exportOptions: { columns: [0, 1, 2, 3] } } ] }); $('#example td').css('white-space','initial');
I uploaded the sample code in jsfiddle, while i go for pdf its some of the columns values not wrapping
https://jsfiddle.net/mhdakta/gtps8cLb/13/
Upvotes: 0
Views: 2084
Reputation: 98
You need to add customize, to pdf export the css also on pdf
$('#example').dataTable({
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'Excel',
text:'Export to excel'
//Columns to export
//exportOptions: {
// columns: [0, 1, 2, 3,4,5,6]
// }
},
{
extend: 'pdfHtml5',
title: 'PDF',
text: 'Export to PDF',
//Columns to export
exportOptions: {
columns: [0, 1, 2, 3]
},
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 = [ '63%', '13%', '13%', '13%'];
}
}
]
});
$('#example td').css('white-space','initial');
Upvotes: 1