I work on angular 7 app i export data to excel it generate file excel but cannot open it
why and how to solve issue
my code used as below
- public exportAsExcelFile(json: any[], excelFileName: string): void {
- const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
- const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
- const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'buffer' });
- this.saveAsExcelFile(excelBuffer, excelFileName);
- }
- private saveAsExcelFile(buffer: any, fileName: string): void {
- const data: Blob = new Blob([buffer], {
- type: EXCEL_TYPE
- });
- const today = new Date();
- const date = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '_';
- const time = today.getHours() + "-" + today.getMinutes() + "-" + today.getSeconds();
- const name = fileName + date + time;
- FileSaver.saveAs(data, name + EXCEL_EXTENSION);
- }
- getDataByRevision(RevId : any)
- {
-
- console.log(this.reportdetailslist);
- this.exportAsExcelFile(this.reportdetailslist,'datarevision');
- }
it download and generate file excel but it is not open
I think problem on excel it self so i open new angular app and export to excel
it is ok exporting without any issue
this meaning i have some issue on my code above
can you help me please
Excel generating attached with post or thread