I have 2 buttons Excel and CSV to export into excel and csv sheets respectively for jquery datatable, Till now our jquery datatable data is getting exported and downloaded into an excel and csv files fine. But my problem here is after export into excel sheet the file name is also inserted into the first row of excel sheet along with datatable data. I want to remove that file name because as I need only the datatable data.
$(document).ready(function () {
$('#example thead tr:eq(1) th').each( function () {
var title = $('#example thead tr:eq(0) th').eq( $(this).index() ).text();
if(title!="Action"){
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
}
} );
var table = $('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
extend: 'excel',
title: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val()
},
{
extend: 'csv',
title: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val()
}
],
"bInfo": false,
fixedHeader: true,
"iDisplayLength": 100,
} );
});
My html Datatable is:
<table class="table table-hover table-condensed dataTable no-footer table-bordered" id="example" role="grid" >
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th>Column5</th>
<th>Column6</th>
<th>Column7</th>
<th>Column8</th>
<th>Column8</th>
<th>Column10</th>
</tr>
</thead>
<tbody>
<td>---</td>
-----------
</tbody>
</table>
My Problem is File name as "My_Report_startDate_endDate.xls" is getting inserted into the first row in the exported excel sheet. I want to remove that file name from the excel sheet. CSV file data is getting exported fine. Any help would be appreciated. Thanks.