【发布时间】:2017-09-14 10:40:46
【问题描述】:
我有 2 个 Excel 和 CSV 按钮分别导出到 excel 和 csv 表中用于 jquery 数据表,到目前为止,我们的 jquery 数据表数据正在导出并下载到 excel 和 csv 文件中。但是我的问题是在导出到 Excel 工作表后,文件名也与数据表数据一起插入到 Excel 工作表的第一行。我想删除该文件名,因为我只需要数据表数据。
$(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 文件数据导出正常。任何帮助,将不胜感激。谢谢。
【问题讨论】:
标签: jquery datatables