Reputation: 317
So I need to generate an excel spreadsheet based on data from DB. Once I add in all the data from the DB I need to add in a new row at the bottom that says when the spreadsheet was generated like so:
I don't know how to get the cells to merge here, I can't use worksheet.mergeCells()
since I don't know how many rows of data there will be in the DB. How would I merge the cells when using worksheet.addRow()
?
Upvotes: 3
Views: 15791
Reputation: 103
I have come across a similar problem and have used something close to this:
const newRow = worksheet.addRow(["This report is..."]);
const currentRowIdx = worksheet.rowCount; // Find out how many rows are there currently
const endColumnIdx = worksheet.columnCount; // Find out how many columns are in the worksheet
// merge by start row, start column, end row, end column
worksheet.mergeCells(currentRowIdx, 1, currentRowIdx, endColumnIdx );
Upvotes: 7