Skip to Content

2 Comments

You must be Logged on to comment or reply to a post.

  1. S B
    Hi Perumal,

    Im using your code to read and excel file and print output but it doesnt show any output.

    Following is the code that im using.

    public void readfile(){
              System.err.println(“readfile called”);
                     try{
                        System.err.println(“inside try”);
                        InputStream fs = new FileInputStream(“c:/GL/Book3.xls”);
                     //POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(“Book3.xls”));
                        System.err.println(“created filesystem”);
                        
                        HSSFWorkbook wb = new HSSFWorkbook(fs);
                        System.err.println(“created workbook”);
                        
                        HSSFSheet sheet = wb.getSheetAt(0);
                        System.err.println(“picked up sheet”);
                        
                        for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
                                  HSSFRow row = (HSSFRow)rit.next();
                                  System.err.println(“first FOR printing row :- ” + row);
                                  for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
                                       HSSFCell cell = (HSSFCell)cit.next();
                                       :- ” + cell.getStringCellValue()+”\t”);
                                  }
                             }

                        
                        
                        
                        
                        
                     }catch(Exception e){
         System.out.print(“Exception Occured ” + e.toString());      
                     }

    }

    It prints till the line : System.err.println(“inside try”);

    After that there is no output.

    Any suggestions.

    (0) 
    1. S B
      Typing error.

      Please read “:- ” + cell.getStringCellValue()+”\t”);” as below.

      System.err.println(“second FOR printing cell :- ” + cell.getStringCellValue()+”\t”);

      (0) 

Leave a Reply