1

嗨,我正在使用节点的 exceljs 库,并且我正在读取一个文件,用作我们的 excel 的模板,我想将 addrows 函数与列的标题属性一起使用,但我在文档中没有看到如何将标题放在与第一行不同的另一行。

我正在这样做。

var headers = [
  {header:'Cliente',key:'client_name'  ,width: 18}, //i need something like startRow:2
  {header:'N° Visitas',key:'visits'  ,width: 10},
  {header:'Visitas Periodo Anterior',key:'visits_old'  ,width: 10},
  {header:'Ultima visita',key:'last_visit',style: { numFmt: 'DD/MM/YYYY HH:mm:ss' },width: 22},
  {header:'Ultima Persona en Visitarlo',key:'device_name'  ,width: 18}
];

var libro  = workbook.xlsx.readFile(template_file)
  .then(function() {
    var worksheet = workbook.getWorksheet(1);

    worksheet.columns = headers;
    worksheet.addRows(data);

    //row.height=40;
    worksheet.getRow(1).hidden=false;
    worksheet.getRow(2).hidden=false;

    //row.height=40;
    workbook.xlsx.writeFile(output)

注意:对不起,如果我拼错了什么。

4

1 回答 1

1
var dobCol = worksheet.getRow(1); // You can define a row like 2 , 3

dobCol.header = [{
{header:'Cliente',key:'client_name'  ,width: 18}, //i need something like startRow:2
  {header:'N° Visitas',key:'visits'  ,width: 10},
  {header:'Visitas Periodo Anterior',key:'visits_old'  ,width: 10},
  {header:'Ultima visita',key:'last_visit',style: { numFmt: 'DD/MM/YYYY HH:mm:ss' },width: 22},
  {header:'Ultima Persona en Visitarlo',key:'device_name'  ,width: 18}
}];
于 2019-01-23T13:45:22.780 回答