ExcelJS fill the multiple cells of excel with for loop

Viewed 36

I have an excel template like this: enter image description here

The data I get is sadly just an 1D array like:

data = [a-b, 24, c-d, 25, g-h, 26, e-f, 27, a-c, 24, b-d, 25, e-g, 26, f-h, 27, a-e, 24, e-g, 25, b-f, 26, d-h, 27];

I am using NodeJS and Exceljs NPM package.

So I need to somehow fill the cells C95:C98, F95:F98, I95:I98.. This similar (but not the same pattern) will apply to other few tables in the same worksheet, so I need to do this with loop.

I am havin trouble with filling the multiple lines and also to fill the overy other value from my array, because i already have an a-b, c-d, g-h,... inserted in excel (I can overwrite, that is not a problem).

Code for now is:

 for (let i = 1; i < 9; i++) {
  console.log(dimensionalCheck[i]);

  let rowNum = 95;
  rowNum++;
  let row = worksheet.getRow(rowNum);
  row.getCell(3).value = dimensionalCheck[i + 1];
  row.commit();
}

But what I get as return is only this: enter image description here

0 Answers
Related