Skip to content

How to set numFmt (styles) by multiple cells in range? #1679

Answered by Siemienik
Aftor asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! ExcelJS has powerfull class named Range. For that purpose what you need, this code should work:

  // @ts-ignore
  import Range from 'exceljs/lib/doc/range';

  const style = {numFmt:'### ### ### ###'};

  const range = new Range('B5','C99');

  // There is no `forEachAddress` in a index.d.ts
  // Issue tracked by: @link {https://github.com/exceljs/exceljs/issues/1681}
  // @ts-ignore 
  range.forEachAddress((address) => {worksheet.getCell(address).style = {...style} });

Source code

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@skypesky
Comment options

@Siemienik
Comment options

@Siemienik
Comment options

@skypesky
Comment options

@Aftor
Comment options

Answer selected by Siemienik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants