Iwark / spreadsheet

Google Go (golang) library for reading and writing spreadsheet files on Google Docs.
MIT License
382 stars 53 forks source link

Finding rows/columns by checking with the value #31

Closed neymarsabin closed 5 years ago

neymarsabin commented 5 years ago

If we are given some value, Can we determine the position of the value in the spreadsheet ?

Expected: If a value is 28, Can I get the position like row = 10, column = 5. Is there any way I can get this type of behaviour ?

Iwark commented 5 years ago

@neymarsabin Hi, you may need to scan all the cells which value is 28. It will be something like this:

func FindPos(val string) (int, int) {
  for row, cells := range sheet.Rows {
    for column, cell := range cells {
      if cell.Value == val {
        return row, column
      }
    }
  }
  return -1, -1
}
neymarsabin commented 5 years ago

Huge thanks for your help. @Iwark