title: Java - Need help getting row # of a specific value
body: <p>i'm having a bit of trouble getting the row number of a specific string. Let's say I have a cell content = "HC" at row 9 and using the method findRow(sheet, "HC"). I should get a return value of 9, but right now the return is 0. </p>
  
  <p>The purpose of the excelSheetFinder function is after the row number is returned from findRow(), I can get the cells from a specific column that I input as the parameters(enCol and frCol).</p>
  
  <p>Any help is appreciated!</p>
  
  <pre><code>public static String[] excelSheetFinder(String value, int enCol, int frCol) throws IOException{
      String[] shortNames = new String[2];
      File excelFile = new File("excel.xlsx");
      FileInputStream inputExcelFile = new FileInputStream(excelFile);
      XSSFWorkbook wb = new XSSFWorkbook(inputExcelFile);
      XSSFSheet sheet = wb.getSheetAt(0);
  
      int shortNameRow = findRow(sheet, value);
  
      System.out.println(shortNameRow);
  
      Row r = sheet.getRow(shortNameRow);
      String enCell = r.getCell(enCol).toString();
      String frCell = r.getCell(frCol).toString();
      shortNames[0] = enCell;
      shortNames[1] = frCell;
  
      return shortNames;
  }
  
  private static int findRow(XSSFSheet sheet, String value){
      //to find row number so we can search through that specific column
      int gotRow = 0;
      for (Row row: sheet){
          for (Cell cell: row){
              final DataFormatter df = new DataFormatter();
              final XSSFCell cellVal = (XSSFCell) row.getCell(row.getRowNum());
              String valueAsString = df.formatCellValue(cellVal);
              if (valueAsString.trim() == value){
                  gotRow = row.getRowNum();
              }
          }
      }
      return gotRow;  
  }
  </code></pre>