dip s

dip s

  • NA
  • 256
  • 82.5k

How to export data table to excel file at 5th row in angular 6

Dec 23 2020 12:17 PM
Hi, 
I have a data table having employee information (Employee No, Name, Designation) from back end, which I want to show in a report. That report should get exported in excel file. I have written following code in angular 6.
  1. const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(result);    
  2. const wb: XLSX.WorkBook = { Sheets: { 'data': ws }, SheetNames: ['data'] };          
  3. const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });    
  4. this.saveExcelFile(excelBuffer, this.filename);     
  1. saveExcelFile(buffer: any, fileName: string): void {  
  2.  const data: Blob = new Blob([buffer], { type: this.fileType });  
  3.  saveAs(data, fileName + this.fileExtension);  
  4. }  
result is having my data table values. Above code works fine.
It wirtes/exports data table in excel file from1st row.
What I want is,
In excel sheet, I want to merge columns from A1: E1  and I have to show client name there.
Then I want to merge columns from A2:E2 and I have to show client address threre.
Similarly ,I want to show Report name as "Employee Information"  in 3rd row of excel sheet.
And from row no 5 in excel sheet ,employee information (data table) should get displayed
 
How can I do this?
Any help would be appreiated. Thank you. 

Answers (1)