excel4node icon indicating copy to clipboard operation
excel4node copied to clipboard

Comparing cell values?

Open andrewgura opened this issue 6 years ago • 3 comments

I have an array var names = ["Bill", "Bill", "Bill"]; and I have creating the cells through a for loop

for(var i = 0; i < names.length; i++) {
  ws.cell(2 + i, 1).string(name[i]);
}

and if I try to do a basic comparison like

if(ws.cell(2 + i, 1).string(name[i]) == ws.cell(2 + i, 1).string(name[i])) {
  console.log(true)
}

It doesnt work, my goal is to combine the cells together if they are equal so this would end up being ws.cell(2,1,4,1,true).string(name[i]); so it wont be combined 3 cells here. Is there a way I can compare the cell values?

I know in this example, I could do it without comparing but it is a more crucial in other ways for me

andrewgura avatar Oct 10 '18 15:10 andrewgura

ws.cell(x,y).string("") method is meant for storing data in the cells, not reading from the cells. So you need to compare values first, and then store them in properly formatted/merged cell.

pkolawa avatar Oct 10 '18 17:10 pkolawa

Can we close the issue?

pkolawa avatar Oct 11 '18 06:10 pkolawa

Yes

andrewgura avatar Oct 11 '18 15:10 andrewgura