RockBoro
RockBoro

Reputation: 2473

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'} ;
}

Upvotes: 7

Views: 21795

Answers (1)

miken32
miken32

Reputation: 42701

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'} ;
}

Upvotes: 14

Related Questions