1 Reply Latest reply: Sep 29, 2013 5:39 AM by edbd9524-ba0c-458b-b526-086de9a3819e RSS

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

    edbd9524-ba0c-458b-b526-086de9a3819e

      test;



      java.io.BufferedInputStream;


      java.io.FileInputStream;


      java.io.IOException;


      java.io.InputStream;


      java.util.Iterator;


      org.apache.poi.poifs.filesystem.POIFSFileSystem;


      org.apache.poi.hssf.usermodel.HSSFCell;


      org.apache.poi.hssf.usermodel.HSSFSheet;


      org.apache.poi.hssf.usermodel.HSSFWorkbook;


      org.apache.poi.hssf.usermodel.HSSFRow;



      class ReadExcel {



      public static void main( String [] args ) {


      try {



      new BufferedInputStream(


      // new FileInputStream("C:/punnam/sample1.xls"));


      new FileInputStream(args[0]));


      new POIFSFileSystem( input );


      new HSSFWorkbook(fs);






      while( rows.hasNext() ) { 



      out.println("\n");



      while( cells.hasNext() ) {




      if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType())


      out.print( cell.getNumericCellValue()+"     " );


      else


      if(HSSFCell.CELL_TYPE_STRING==cell.getCellType())


      out.print( cell.getStringCellValue()+"     " );


      else


      if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType())


      out.print( cell.getBooleanCellValue()+"     " );


      else


      if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType())


      out.print( "BLANK     " );


      else


      out.print("Unknown cell type");









      catch ( IOException ex ) {