natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 215 forks source link

Comparing cell values? #246

Open andrewgura opened 6 years ago

andrewgura commented 6 years ago

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

pkolawa commented 6 years ago

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 commented 6 years ago

Can we close the issue?

andrewgura commented 6 years ago

Yes