I’m trying using excel4node to convert my data into excel,
here is my code:
names = ['AA','BB','CC']
names.forEach((title, index) => {
sheet.cell(1, index, 1, index + 1, true).string(title);
index += 2;
});
the problem is i want to only use odd number as index in this loop.
expecting sheet.cell code in loop like this:
sheet.cell(1, "1", 1, "2", true).string(title[0])
sheet.cell(1, "3", 1, "4", true).string(title[1])
sheet.cell(1, "5", 1, "6", true).string(title[2])
so how do i skip the even index number in for each loop
I tried used index += 2 or in the beginning of the loop (title, index = 1) or use continue, but won’t work…
please help, thanks
>Solution :
I think you can do like this.
sheet.cell(1, 2 * index + 1, 1, 2 * index + 2, true).string(title);