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
For those who are still looking for a working answer.
public export() {
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(this.myDataModels);
/* generate workbook and add the worksheet */
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, worksheet, 'Sheet1');
/* save to file */
XLSX.writeFile(wb, this.createFileName());
}
This will save as an xlsx file automatically Got this from https://github.com/SheetJS/js-xlsx/tree/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/demos/angular2