I want to receive the Excel data and put the value in the Excel column as a loop statement.
I want to put it in with the code below, what should I do?
//read file
const workbook = XLSX.readFile("test.xlsx");
//put value
workbook.Sheets.Sheet1.B2.v = 2000
workbook.Sheets.Sheet1.B3.v = 3000
workbook.Sheets.Sheet1.B4.v = 4000
You can use bracket notations along with a for loop to do this.
With [] notation, you can use a variable to access a property of an object.
Initialize with a suitable value and run up til some limit. Here is sample code:
const workbook = XLSX.readFile("test.xlsx");
let cellsLimit = 100;
for(let i = 1 ; i <= cellsLimit; i++){
let keyName = 'B' + i;
workbook.Sheets.Sheet1[keyName].v = 1000 + (i*1000)
}