title: Apache POI rows number
body: <p>I am using Apache POI java and want to get the total number of rows which are not empty. I successfully processed a whole row with all its columns. Now I am assuming that I get an excel sheet with multiple rows and not a single row...so how to go about that? I was thinking of getting total number of rows (int n) and then loop until i&lt;=n but not sure.</p>
  
  <p>Suggestions are most welcome :)</p>
  
  <p>Note: Apache  POI version is 3.8. I am not dealing with Xlsx format...only xls.</p>
  
  <p>Yes I tried this code but got 20 in return....which is not possible given I have only 5 rows </p>
  
  <pre><code>FileInputStream fileInputStream = new FileInputStream("COD.xls");
              HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
              HSSFSheet worksheet = workbook.getSheet("COD");
              HSSFRow row1 = worksheet.getRow(3);
              Iterator rows = worksheet.rowIterator(); 
              int noOfRows = 0;
              while( rows.hasNext() ) {
                  HSSFRow row = (HSSFRow) rows.next();
                  noOfRows++;                
              }
              System.out.println("Number of Rows: " + noOfRows);
  </code></pre>