title: JAVA - Read excel from a specific row
body: <p>i have some problem here, i want to java read my excel document, but what if there is some of row that i dont want to read, i want to skip that. here is my excel example : lets assume i want my java program read start from row 3
  <a href="http://i.stack.imgur.com/5zslt.png" rel="nofollow">excel example</a></p>
  
  <p>and here is my code:</p>
  
  <pre><code>public static void main(String[] args) {
      try{
          Class.forName("com.mysql.jdbc.Driver");
          Connection con = (Connection) DriverManager.getConnection(dbconnection+","+dbusername+","+dbPass);
          con.setAutoCommit(false);
          PreparedStatement pstm = null ;
          File file = new File(filepath);
          FileInputStream input = new FileInputStream(file);
          System.out.println(file);
          if (!file.toString().contains("xlsx")){
              System.out.println("hssf");
              POIFSFileSystem fs = new POIFSFileSystem(input);
              HSSFWorkbook wb = new HSSFWorkbook(fs);
              HSSFSheet sheeth = wb.getSheetAt(0);
  
              Row row;
              for(int i=0; i&lt;=sheeth.getLastRowNum(); i++){
                  row = sheeth.getRow(i);
  
                  int id          = (int) row.getCell(0).getNumericCellValue();
                  String nama     = row.getCell(1).getStringCellValue();
                  String rm       = row.getCell(2).getStringCellValue();
                  String nama_ro  = row.getCell(3).getStringCellValue();
                  String no_pks   = row.getCell(4).getStringCellValue();
                  String ket      = row.getCell(5).getStringCellValue();
                  String lob      = row.getCell(6).getStringCellValue();
  
                  String sql = "INSERT INTO testdatapks VALUES('"+id+"','"+nama+"','"+rm+"','"+nama_ro+"','"+no_pks+"','"+ket+"','"+lob+"')";
                  pstm = (PreparedStatement) con.prepareStatement(sql);
                  pstm.execute();
                  System.out.println("Import rows "+i);
              }
  
              con.commit();
              pstm.close();
              con.close();
              input.close();
              System.out.println("Success import excel to mysql table");
          }
  </code></pre>
  
  <p>i assume we never know the user or client document, he/she can make a excel which the value start from any row, we never know. what if the excel he uploaded the value start from row 4? or row 5? or maybe first row? 
  can someone help me to do that? thanks before</p>