我有2个按钮Excel和CSV导出到jQuery数据表格的Excel和CSV表格,直到现在我们的jQuery数据表格数据被导出并下载到excel和csv文件中。但是我的问题这里是在导出到excel表格后,文件名也被插入excel表格的第一行以及数据表数据。我想删除该文件名,因为我只需要数据表数据。如何使用数据表导出excel文件后从Excel表中删除file_name?
$(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,
});
});
我的HTML数据表是:
<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_Report_startDate_endDate.xls” 是越来越插入导出Excel工作表的第一行。我想从Excel工作表中删除该文件名。 CSV文件数据正在导出正常。任何帮助,将不胜感激。谢谢。
感谢您的快速回复。但它不工作。这次我们的应用程序
这一行就像所有列中的标题或什么? 如果发生这种情况,那么它是由Datatable自己创建的 – akbansa
是的,你是正确的插入像第一行中的所有列的标题,但从第二行开始列标题也正确插入像Column1 Column2 Column3连同值在每个相应的列下。如何解决这个问题? –