public int getRowIndex ( String sheetName , String key ) { logger . entering ( new Object [ ] { sheetName , key } ) ; int index = - 1 ; Sheet sheet = fetchSheet ( sheetName ) ; int rowCount = sheet . getPhysicalNumberOfRows ( ) ; for ( int i = 0 ; i < rowCount ; i ++ ) { Row row = sheet . getRow ( i ) ; if ( row == null ) { continue ; } String cellValue = row . getCell ( 0 ) . toString ( ) ; if ( ( key . compareTo ( cellValue ) == 0 ) && ( ! cellValue . contains ( "#" ) ) ) { index = i ; break ; } } logger . exiting ( index ) ; return index ; }
Search for the input key from the specified sheet name and return the index position of the row that contained the key