Те кто вдруг случайно столкнется с exceljs вот скрипка которая эскпортирует несколько таблиц в эксель методом blob ну там само определитесь как вам будет удобно)) недеюсь кому-то помог)
HTML:
<div class="container">
<table id="table" class='table_for_export_excel'>
<thead id="thead">
<tr>
<th>number</th>
<th>head</th>
<th>value</th>
<th>test</th>
<th>ging</th>
</tr>
</thead>
<tbody id="tbody">
<tr>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
</tbody>
<tfoot id="tfoot">
<tr>
<td>foot</td>
<td>foot</td>
<td>foot</td>
<td>foot</td>
<td>foot</td>
</tr>
</tfoot>
</table>
<table id="table" class='table_for_export_excel'>
<thead id="thead">
<tr>
<th>head2</th>
<th>head2</th>
<th>head2</th>
<th>head2</th>
<th>head2</th>
</tr>
</thead>
<tbody id="tbody">
<tr>
<td>body2</td>
<td>body2</td>
<td>body2</td>
<td>body2</td>
<td>body2</td>
</tr>
</tbody>
<tfoot id="tfoot">
<tr>
<td>foot2</td>
<td>foot2</td>
<td>foot2</td>
<td>foot2</td>
<td>foot2</td>
</tr>
</tfoot>
</table>
</div>
JS:
var workbook = new ExcelJS.Workbook();
var worksheet = workbook.addWorksheet();
var getting_table = function(){
var post_class = $('.table_for_export_excel');
post_class.each(function(index, element){
var thead = [];
//loop for current table
$(element).each(function (index_head, element_head){
var elements_td = $(element_head).find("th");
$(elements_td).each(function(index_th, element_th){
// debugger;
thead.push($(element_th).text());
// console.log(element_th);
});
$(thead).each(function(index_val, el_body){
thead.push($(el_body).text());
console.log(el_body);
});
worksheet.addRow(thead);
worksheet.addRow(" ");
});
var body = [];
//loop for current table body
$(element).each(function (index_head, element_head){
var elements_td = $(element_head).find("#tbody tr td");
$(elements_td).each(function(index_td, element_td){
// debugger;
body.push($(element_td).text());
});
$(body).each(function(index_val, el_body){
thead.push($(el_body).text());
console.log(el_body);
});
worksheet.addRow(body);
worksheet.addRow(" ");
});
//loop for current table footer
$(element).each(function (index_head, element_head){
var footer = [];
var elements_td = $(element_head).find("#tfoot tr td");
$(elements_td).each(function(index_th, element_th){
// debugger;
footer.push($(element_th).text());
});
$(footer).each(function(index_val, el_footer){
footer.push($(el_footer).text());
});
worksheet.addRow(footer);
worksheet.addRow(" ");
});
// debugger;
});
};
getting_table();
workbook.xlsx.writeBuffer().then(function (data) {
var blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
saveAs(blob, "export_excel.xlsx");
});