title: How to handle empty cell using apache-poi
body: <p>How can I handle an empty cell using poi jars? This is the code:</p>
  
  <pre><code>public static String getdata(String SheetName, String ObjectLabel, int row) throws InvalidFormatException, IOException{
      String objvalue = null;
      FileInputStream fi = new FileInputStream(dir + "\\src\\pack\\TaurusRefactored\\TaurusRegistration1.xls");
      Workbook w = WorkbookFactory.create(fi);
      Sheet s = w.getSheet(SheetName);
      int rowcount = s.getLastRowNum();
      int columncount = s.getRow(0).getLastCellNum();
      for (int i = 0; i &lt; columncount; i++) {
          String objlabl = s.getRow(0).getCell(i).getStringCellValue();
          if (objlabl.equals(ObjectLabel)) {
              switch (s.getRow(row).getCell(i).getCellType()) {
              case Cell.CELL_TYPE_STRING:
                  objvalue = s.getRow(row).getCell(i).getStringCellValue().trim();
                  break;
              case Cell.CELL_TYPE_NUMERIC:
                  objvalue = Integer.toString((int) s.getRow(row).getCell(i).getNumericCellValue());
                  break;
              case Cell.CELL_TYPE_BLANK:
                  objvalue = "";
              default:
                  break;
              }
          }
      }
       return objvalue;
  }
  </code></pre>
  
  <p>I am getting the error the switch statement: <code>(s.getRow(row).getCell(i).getCellType())</code>  while taking the data from an empty cell.</p>