title: How to get number of rows in excel which contains data(excluding blank or empty cells) in one particular column using JAVA, APACHE POI
body: <p>Trying to read excel where i need to extract number of rows in one column which contains data or value except blank or empty cells. And store cell values inside string array I tried using sheet.getLastRowNum() but didn't worked for me. Can anyone suggest the way out.</p>
  
  <p>following is what I tried so far</p>
  
  <pre><code>private void readExcel() 
  {
      InputStream ExcelFileToRead = new FileInputStream("C:/Users/Public/template.xlsx");
      XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
      XSSFWorkbook test = new XSSFWorkbook();
      XSSFSheet sheet = wb.getSheetAt(0);
      XSSFRow row=null;
      XSSFCell cell;   
      String[] strArray=null;
      int i=10;
  
      for(i=10;i&lt;this.sheet.getLastRowNum();i++)
      {
          if( (getCell("G"+i)!=null) ) 
          {                
              strArray[index]= strArray[index] + getCell("G"+i).toString() ;
          }           
      }
        System.out.println(strArray);
  }
  
  private XSSFCell getCell(String cellName)
  {
      Pattern r = Pattern.compile("^([A-Z]+)([0-9]+)$");
      Matcher m = r.matcher(cellName);
      if(m.matches()) 
      {
          String columnName = m.group(1);
          int rowNumber = Integer.parseInt(m.group(2));
          if(rowNumber &gt; 0) 
          {
              return wb.getSheetAt(0).getRow(rowNumber-1).getCell(CellReference.convertColStringToIndex(columnName));
          }
      }
      return null;
  }
  </code></pre>