Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how write to cell that spans multiple columns using excelJS?

can I create an excel cell which spans multiple columns using excelJS?

I tried getCell with a cell range. But the value was set in only the first column.

function colSpamDemo( )
{
  let wb = new ExcelJS.Workbook();
  let ws = wb.addWorksheet('Export');

  ws.getCell('A1:C1').value = 'This price list supercedes all prior price lists.';
  ws.getCell('A1:C1').alignment = { horizontal:'center'} ;
}
like image 383
RockBoro Avatar asked Mar 06 '23 15:03

RockBoro


1 Answers

You can create a merged cell, which sounds like what you are looking for.

function colSpamDemo( )
{
  let wb = new ExcelJS.Workbook();
  let ws = wb.addWorksheet('Export');

  ws.mergeCells('A1:C1');
  ws.getCell('A1').value = 'This price list supercedes all prior price lists.';
  ws.getCell('A1').alignment = { horizontal:'center'} ;
}
like image 188
miken32 Avatar answered Mar 09 '23 05:03

miken32