title: Read data from .xlsx file in Java
body: <p>I am trying to extract the data from a .xlsx file for that I am using POI-bin-3.11-beta2-2.jar,here my <code>FileInputStream</code> is created but the issue is in workbook. I think my xssf reference is not able to reach at the file location. </p>
  
  <pre><code>public class DemoExcel
  {
      public static void main(String[] args) throws Exception
      {
          //File excel = new File("C:\\Users\\aditya.lodha\\Desktop\\test.xlsx");
          FileInputStream fis = null;
  
          try{
              fis = new FileInputStream(new File("C:\\Users\\aditya.lodha\\Desktop\\test.xlsx"));
              System.out.println("file found");
          }
          catch(FileNotFoundException e){
              System.out.println("file not found");
              e.printStackTrace();
          }
          System.out.println(fis.toString());
          XSSFWorkbook wb = new XSSFWorkbook(fis);
          //HSSFWorkbook wb = new HSSFWorkbook(fis);
          System.out.println(wb.toString());
          XSSFSheet sh = wb.getSheet("tabledata");
          //HSSFSheet sh = wb.getSheet("XYZ");
          //System.out.println(sh.toString());
          int rowNum = sh.getLastRowNum()+1;
          System.out.println(rowNum);
          int colNum = sh.getRow(0).getLastCellNum();
          System.out.println(colNum);
          String data[][] = new String [rowNum][colNum];
          for(int i=0;i&lt;rowNum;i++)
          {
              XSSFRow row = sh.getRow(i);
              for(int j=0;j&lt;colNum;j++)
              {
                  XSSFCell col = row.getCell(j);
                  String value = celltoString(col);
                  data[i][j] = value;
              }
          }
  
          for(int i=0;i&lt;rowNum;i++)
          {
              for(int j=0;j&lt;colNum;j++)
              System.out.println(data[i][j]);
  
          }
      }
      private static String celltoString(XSSFCell col)
      {
          int type;
          Object result;
          type = col.getCellType();
          switch (type)
          {
              case 0:
              result = col.getNumericCellValue();
              break;
  
              case 1:
              result = col.getStringCellValue();
              break;
  
              default:
              System.out.println(type);
              throw new RuntimeException("Runtime Exception");
          }
          return result.toString();
      }
  }
  </code></pre>
  
  <p>the error I am getting </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    org/apache/xmlbeans/XmlException<br>
          at demo.DemoExcel.main(DemoExcel.java:31)<br>
        Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException<br>
          at java.net.URLClassLoader$1.run(Unknown Source)<br>
          at java.security.AccessController.doPrivileged(Native Method)<br>
          at java.net.URLClassLoader.findClass(Unknown Source)<br>
          at java.lang.ClassLoader.loadClass(Unknown Source)<br>
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)<br>
          at java.lang.ClassLoader.loadClass(Unknown Source)<br>
          at java.lang.ClassLoader.loadClassInternal(Unknown Source)<br>
          ... 1 more</p>
  </blockquote>