I have a data table that is dynamically populated using Angular 4. I would like to export the table to excel. How can I achieve this in Angular 4. I\'m looking for .xls and not
You can only use xlsx
library to write and save excel file at the same time using XLSX.writeFile()
exportExcel(data: any[]){
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(data);
const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
XLSX.writeFile(workbook, 'my_file.xls', { bookType: 'xls', type: 'buffer' });
}