我有问题。我有两个桌子(一个在另一个里面)
<table>
<thead>
<th>title 1</th><th>title 2</th>
</thead>
<tbody>
<tr>
<td>colum1</td>
<td>colum2</td>
</tr>
<tr>
<table>
<thead>
<th>title 1</th><th>title 2</th>
</thead>
<tbody>
<tr><td>Colum1 table 2 </td></tr>
</tbody>
</table>
</tr>
</tbody>
</table>
类似这样的事情。 我的问题是当我使用js-xlsx在xls中提取此表时。第二个表导出两次,第一个表仅导出一行,第二个表很好。 我要删除第一个导出。
这是我的js代码
var elt = document.getElementById(dataId);
elt = elt.cloneNode(true);
var workbook = XLSX.utils.book_new();
if (dataId == 'distributorInfoTable'){
for(var i = elt.rows.length - 1; i > 0; i--) {
var rowToDelete = elt.rows[i].getElementsByTagName('distributorsTable')[0];
elt = elt.cloneNode(true);
var workbook = XLSX.utils.book_new();
if (dataId == 'distributorInfoTable'){
for(var i = elt.rows.length - 1; i > 0; i--) {
var rowToDelete = elt.rows[i].getElementsByTagName('distributorsTable')[0];
rowToDelete = rowToDelete.cloneNode(true);
var filmName = elt.rows[i].getElementsByTagName('td')[0];
filmName = $(filmName).attr('filmName');
filmName = filmName.substring(0,31);
var wb = XLSX.utils.table_to_sheet(rowToDelete);
XLSX.utils.book_append_sheet(workbook, wb, filmName);
$(elt.rows[i].getElementsByTagName('table')).remove();
}
var wb = XLSX.utils.table_to_sheet(elt);
XLSX.utils.book_append_sheet(workbook, wb, "Resumen ");
XLSX.write(workbook, {bookType:'xlsx', bookSST:true, type: 'base64'});
XLSX.writeFile(workbook, reportName+'.xlsx');
}
任何人都可以帮助我吗?