1

Hi i'm working with the exceljs library for node, and I'm reading a file, used as template for our excels, I want to use the addrows function with the headers properties of the columns, but I dont see in the documentation how to put the header on another row different from the first.

I am doing this.

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)

Note: sorry if i misspell something.

1 Answer 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}
}];
Sign up to request clarification or add additional context in comments.

1 Comment

I tried it, and in my case the appended rows started from: var dobCol = worksheet.getRow(4), tho the header of the table were still on the first row, tho what I needed was to set the start row form header columns to be 4th row:(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.