You can use this custom script, if you need to copy to clipboard all data from table;
html:
<button class='btnclipboard' data-source='tableStudents'> Copy table </button>
<table id="tableStudents">
<thead>
<th> user_id </th>
<th> Name </th>
</thead>
<tbody>
<tr>
<td> 123 </td>
<td> Proba </td>
</tr>
<tbody>
</table>
<script>
$('.btnclipboard').click(function(e) {
e.preventDefault();
copyTableToClipboard($(this).data('source'));
});
function copyTableToClipboard() {
var clipboard=new Clipboard('.btnclipboard',{
text: function(trigger) {
var txt=[];
var headColumns = [];
$("#tableStudents th").each(function(){
var textColumn = $(this).text();
if(textColumn == null || textColumn == "") {
textColumn = $(this).attr('title');
}
if(textColumn == undefined || textColumn == null) {
textColumn = "";
}
headColumns.push(textColumn);
// console.log($(this).text());
});
console.log('headColumns', headColumns);
var head=headColumns;
txt.push(head.join("\t"));
var rowColumns=[];
$("#tableStudents tr").each(function(){
var row=[];
$(this).find('td').each(function(){
var textColumn = $(this).text();
if($(this).find("i").hasClass('fa-check')){
textColumn = "1";
}
// if(textColumn == "") {
// // textColumn = $(this).attr('title');
// textColumn = "";
// }
// if(textColumn != null) {
row.push(textColumn);
// }
//console.log($(this).text());
});
if(row.length > 0) {
rowColumns.push(row);
txt.push(row.join("\t"));
}
});
console.log('rowColumns', rowColumns);
return txt.join("\n");
}
});
clipboard.on('success', function(e) {
console.info('Action:', e.action);
e.clearSelection();
if (Notification.permission == "granted")
{
var notification = new Notification('Data copied to clipboard', {
icon: '../dist/img/favicon.png',
body: "You can now paste (Ctrl+v) into your favorite spreadsheet editor !"
});
}else{
console.warn(Notification.permission);
}
});
clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
}
</script>
After you click on the button, your table data should be copied.