AOT的角度构建无法编译promise

时间:2019-05-27 07:25:23

标签: angular exceljs

我正在使用此库https://www.npmjs.com/package/exceljs

用于以角度导出Excel文件 而且即时通讯使用AOT编译时遇到错误,exceljs的promise库无法使用,并且promise无法解决。 使用JIT编译时,一切正常

import { Workbook } from 'exceljs';

   //Create workbook and worksheet
    let workbook: Workbook = new Workbook();
    let worksheet = workbook.addWorksheet('ulist');
    worksheet.columns = [
        { header: 'test', key: 'NameField' },
        { header: 'display', key: 'FieldDisplay', width: 15 },
        { header: 'package', key: 'Field' },
        { header: 'namecus', key: 'NAMEField' },
        { header: 'status, key: 'DescField', width: 10 }
    ];
   //Add Header Row
    let headerRow = worksheet.getRow(1);

    // Cell Style : Fill and Border
    headerRow.eachCell((cell, number) => {
        cell.fill = {
            type: 'pattern',
            pattern: 'solid',
            fgColor: { argb: 'FF0000' },
            bgColor: { argb: 'FF0000' }
        }
        cell.border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } }
    });
    // Add Data and Conditional Formatting
    arrayForExcel.forEach(d => {
        let row = worksheet.addRow(d);
        row.eachCell((cell) => {
            cell.border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } }
        });
    });

     //Generate Excel File with given name 
    workbook.xlsx.writeBuffer().then((data) => { <<---THIS PROMISE NOT GETTING RESOLVED ON AOT COMPILE 
        console.log("let blob");
        let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
        fs.saveAs(blob, 'ulist.xlsx');
    });

workbook.xlsx.writeBuffer()承诺不会在AOT Compile上得到解决,我也不知道为什么,它在JIT complie中运行良好。

我尝试将tsconfig“ target”:“ es5”更改为“ es6” 但似乎不起作用 有想法吗?

0 个答案:

没有答案