Reputation: 11
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.
Upvotes: 1
Views: 12264
Reputation: 11
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}
}];
Upvotes: 1