我有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連同值在每個相應的列下。如何解決這個問題? –