How to append column names to an Excel Export?
How to append column names to an Excel Export?
mjas
Posts: 1Questions: 1Answers: 0
I'm converting my th cells into search bars. However, when I do my Excel export, the column names do not show up. I'd like to append these manually.
Thanks!
<script>
// Setup - add a text input to each header cell
$('.mytable thead th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" size="5" placeholder="'+title+'" />' );
} );
// DataTable
var table = $('.mytable').DataTable( {
"autoWidth": true,
dom: 'Bfrtip',
buttons: [
'excel',
]
} );
// Apply the search
table.columns().eq(0).each(function(colIdx) {
$('input', table.column(colIdx).header()).on('keyup change', function() {
table
.column(colIdx)
.search(this.value)
.draw();
});
$('input', table.column(colIdx).header()).on('click', function(e) {
e.stopPropagation();
});
});
</script>
This discussion has been closed.
Answers
did you have this problem ?