Node.js 使用json数组在ExcelJS中添加行

Node.js 使用json数组在ExcelJS中添加行,node.js,reactjs,exceljs,Node.js,Reactjs,Exceljs,我是React、NodeJS和ExcelJS的新手,我一直在用这个例子来指导自己:我有一个json数组: const objectsFromCols = () =>{ const valuesToExport=[]; rutas.forEach((ruta) => { let rutaExport={ Ruta:ruta.label, Derrotero:ruta.value.descripcion,

我是React、NodeJS和ExcelJS的新手,我一直在用这个例子来指导自己:我有一个json数组:

const objectsFromCols = () =>{
    const valuesToExport=[];
    rutas.forEach((ruta) => {
        let rutaExport={
            Ruta:ruta.label,
            Derrotero:ruta.value.descripcion,
            Inicio:ruta.value.inicio,
            Fin:ruta.value.fin,
            Ciudad:ciudad.nombre
        }
        valuesToExport.push(rutaExport);
    });
    return valuesToExport;
}
我有我的标题:

worksheet.columns=[
        {header: 'Ruta', key:'ruta', width: 12},
        {header: 'Derrotero', key: 'derrotero', width: 60},
        {header: 'Inicio', key: 'inicio', width: 16},
        {header: 'Fin', key: 'fin', width: 16},
        {header: 'Ciudad', key: 'nombre', width: 12}
    ];
我尝试用“rutas”中的数据填充Excel文件,该文件在console.log中成功检索,但使用此方法根本不起作用,只打印标题:

 worksheet.addRows(rutas);
我也试过这个例子:

 // Dump all the data into Excel
   rutas.forEach((e, index) => {
  // row 1 is the header.
  const rowIndex = index + 2
  worksheet.addRow({
    ...e
  })
})
我该怎么办?提前感谢您提供的任何线索