title: java program to read excel file and create an array to insert it to database table
body: <p>I am writing a java program with the help of apache poi to read from excel file.I want to write a program which creates arrays of object from  excel, and  update the DB.</p>
  
  <p>I am able to read the  excel file with the help of apache poi(using the examples provides) but after reading excel file, i am not sure  how to  create array in java which has all the data.
  The first row  represents the  table field (i.e.  column name: EX name,id,etc..)</p>
  
  <p>1)The  logic should be smart enough to detect  columns even if the order are reversed/changed  in excel file.
  Example of table : </p>
  
  <hr>
  
  <p>Code : </p>
  
  <pre><code>XSSFSheet sheet = workbook.getSheetAt(0);
      Iterator &lt; Row &gt;  rowIterator = sheet.iterator();
      while (rowIterator.hasNext()) {
          row = (XSSFRow) rowIterator.next();
          Iterator &lt; Cell &gt;  cellIterator = row.cellIterator();
  
          while ( cellIterator.hasNext()) {
             Cell cell = cellIterator.next();
  
             switch (cell.getCellType()) {
                case Cell.CELL_TYPE_NUMERIC:
                System.out.print( 
                cell.getNumericCellValue() + " \t\t " );
                break;
  
                case Cell.CELL_TYPE_STRING:
                /*System.out.print(
                cell.getStringCellValue() + " \t\t " );
                */break;
             }
          }
          System.out.println();
       }
  </code></pre>