Export data from multiple table to one excel sheet using XLSX

Viewed 315

I was trying to export data from three table into one excel sheet as a one table but it gives one by one how can i get them as a one table.

exportExcel() {

let tbl1 = this.table1.nativeElement;
let tbl2 = this.table2.nativeElement;
let tbl3 = this.table3.nativeElement;

let worksheet_tmp1 = XLSX.utils.table_to_sheet(tbl1);
let worksheet_tmp2 = XLSX.utils.table_to_sheet(tbl2);
let worksheet_tmp3 = XLSX.utils.table_to_sheet(tbl3);

let a = XLSX.utils.sheet_to_json(worksheet_tmp1, { header: 1 });
let b = XLSX.utils.sheet_to_json(worksheet_tmp2, { header: 2 });
let c = XLSX.utils.sheet_to_json(worksheet_tmp3, { header: 12 });

a = a.concat(b).concat(c);

let ws = XLSX.utils.json_to_sheet(a);

const new_workbook = XLSX.utils.book_new();

const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");

XLSX.writeFile(wb, "Class Summary_Report.xlsx");

}

Here what I got

Here what I got.I want to get these three table as one table without having these spaces.

0 Answers
Related