You can use the DataTables extension: DataTables Select
Add to button export options:
modifier: {
selected: true
}
and
select: true
to initialize the DataTable code.
Your new code:
if( $('.clienttable').length > 0 ) {
$('.clienttable').DataTable( {
pageLength: 10,
select: true,
responsive: true,
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{
extend: 'copyHtml5',
exportOptions: {
columns: [1,2,3,4,5,6],
modifier: {
selected: true
}
}
},
{
extend: 'csvHtml5',
exportOptions: {
columns: [1,2,3,4,5,6],
modifier: {
selected: true
}
}
},
{
extend: 'excelHtml5',
exportOptions: {
columns: [1,2,3,4,5,6],
modifier: {
selected: true
}
}
},
{
extend: 'pdfHtml5',
exportOptions: {
columns: [1,2,3,4,5,6],
modifier: {
selected: true
}
},
title: 'List of Clients',
}
],
columnDefs: [
{ targets: [0], orderable: false },
{ targets: [7], orderable: false }
],
"order": [[ 6, "desc" ]]
});
}
Now you can print only selected lines.