how to set Header in a different row?
See original GitHub issueIs there a way to set the headers on a diferent row, other than the first?
I’m trying to do this
`var Excel = require('exceljs');
var workbook = new Excel.Workbook();
var headers = [
{header:'Cliente',key:'client_name' ,width: 18}, // i need something like headerRow: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.properties.defaultRowHeight = 15;
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)
.then(function() {
callback(null,output);
});`
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Set up your header row - Microsoft Support
In the query pane, select Edit to open the Power Query editor. · To confirm that Power Query recognized your headers in the...
Read more >How To Create a Header Row in Excel Using 3 Methods
How to create a header row in Excel by printing · 1. Open Excel and the correct spreadsheet · 2. Find "Page Layout"...
Read more >The Simplest Way to Add a Header Row in Excel - wikiHow
1. Click the View tab. If you want to keep a row of data visible at all times, even when you've scrolled down...
Read more >How to make an Excel header row - Excelchat - Got It AI
Add print title · Click Page Layout tab > Print Titles · In the Page Setup dialog box, Sheet tab, enter row 2...
Read more >Changing the Table Header Row - Spreadsheet.com Support
To change the table header row, select the new row you would like to set as the table header, right-click on the row...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wanted my headers to start from 3rd row and 1st-row 1st cell had some metadata,so what I did was:
Duplicated my headers in 3 rows (1,2,3).
worksheet.duplicateRow(1, 2, true); //duplicate header row 2 times with values and style; in row2 and row3
Added metadata in 1st row
worksheet.getRow(1).values = ['Some meta data'] //Replace row1 headers with "Berry Type";here we pass an array where each index denotes a cells
Removing duplicated headers from 2nd row
worksheet.getRow(2).values = [] //Delete row2 duplicated above in step 1
And here’s my output:
Metadata | | | | – | – | – | – | – | | | | header1 | Header2 | header3 | header4 | header5 1 | 2 | 3 | 4 | 5
I’ve managed to offset the header row by using splice rows set to remove 0 rows and giving it an empty array of the desired amount of rows, just place it after all rows have been added. A similar technique could be applied to columns. Anything you want to add above the header rows will need to be set directly (not using addRow or addRows, so presumably wont work for a streamed file if the rows are already committed?) Or you could specify it in the array parameter of splice in place of the
new Array(offset)
parameter