Я нашел решение с помощью excel. js и файловой заставки. js.
import { Workbook } from 'exceljs';
import * as fs from 'file-saver';
generateExcel(list,header) {
let data:any = [];
for(let i=0;i<list.length;i++){
let arr = [list[i].requisitionId,list[i].applicationid, list[i].candidateid, list[i].unitcode];
data.push(arr);
}
console.log(data);
//Create workbook and worksheet
let workbook = new Workbook();
let worksheet = workbook.addWorksheet('Candidate Report');
//Add Header Row
let headerRow = worksheet.addRow(header);
// Cell Style : Fill and Border
headerRow.eachCell((cell, number) => {
cell.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FFFFFF00' },
bgColor: { argb: 'FF0000FF' }
}
cell.border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } }
})
worksheet.getColumn(3).width = 30;
data.forEach(d => {
let row = worksheet.addRow(d);
}
);
list.forEach((element,index) =>{
worksheet.getCell('E'+(+index+2)).dataValidation = {
type: 'list',
allowBlank: true,
formulae: ['"Selected,Rejected,On-hold"']
};
})
//Generate Excel File with given name
workbook.xlsx.writeBuffer().then((data) => {
let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
fs.saveAs(blob, 'candidate.xlsx');
})
}
`