AdSenseHeader

Reading the Excel Files data using java

When  reading the ".xls" file data  in java. We are Apache POI Api  this poi is used for to read the excel file data .If you want to read the ".xlsx" format file we are adavanced Apache Poi api.

  • First Download the apache poi jar

  • Sample Program for Reading .xls file

Class XlsRead
{
  public static void main(String[] args) throws Exception{

         String filename = "E:\\ramuexcel.xls";
         FileInputStream fis = null;

        try
           {
               fis = new FileInputStream(filename);
             HSSFWorkbook workbook = new HSSFWorkbook(fis);
             HSSFSheet sheet = workbook.getSheetAt(0);
             while (rows.hasNext()) {
                 HSSFRow row = (HSSFRow) rows.next();
               
                 Iterator cells = row.cellIterator();
               
                 while(cells.hasNext())
                 {
                     HSSFCell cell=(HSSFCell) cells.next();
                     if(cell.getCellNum()==3)//Getting 4 th cell data
                     {
                         servicename.add(cell);
                     }
                     if(cell.getCellNum()==6)
                     {
                         serviceDesc.add(cell);
                       }
                   }

            }
        catch(Exception e)
          {
              e.printStackTrace();
           }
     }
}



5 comments:

  1. There is error in program

    ReplyDelete
  2. Good day! I could have sworn I've been to this website before but after reading through some of the post I realized it's new to me. Anyhow, I'm definitely glad I found it and I'll be book-marking and checking back frequently! capitalone.com login

    ReplyDelete
  3. That is really nice to hear. thank you for the update and good luck. Compress JPEG Images Online

    ReplyDelete
  4. Nice post I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this   
    Salesforce Training India 

    ReplyDelete
  5. It's very useful article with inforamtive and insightful content and i had good experience with this information.Enroll today to get free access to our live demo session which is a great opportunity to interact with the trainer directly which is a placement based Salesforce training India with job placement and certification . I strongly recommend my friends to join this Salesforce training institutes in hyderabad practical course, great curriculum Salesforce training institutes in Bangalore with real time experienced faculty Salesforce training institutes in Chennai. Never delay to enroll for a free demo at Salesforce training institutes in Mumbai who are popular for Salesforce training institutes in Pune.

    ReplyDelete

 
Top