-1

I would like to know how to iterate and get the list of cell values from excel file first row or specific row in a sheet using java with poi.

Could anyone please help me to know about this...

Thanks in advance,

DIVA
  • 549
  • 2
  • 11
  • 34
  • google it before asking question.. http://howtodoinjava.com/apache-commons/readingwriting-excel-files-in-java-poi-tutorial/ – RamPrakash Jan 04 '17 at 16:40
  • someone please mark this as duplicate – RamPrakash Jan 04 '17 at 16:41
  • @RamPrakash Why should you want to mark this question as duplicate. I need to know iterating the particular column cells. Do you have idea ? – DIVA Jan 04 '17 at 16:43
  • Did you searched for answer to your question before asking here http://stackoverflow.com/questions/5578535/get-cell-value-from-excel-sheet-with-apache-poi – RamPrakash Jan 04 '17 at 16:49
  • Possible duplicate of [How to do cell iteration of excel in java](http://stackoverflow.com/questions/16215750/how-to-do-cell-iteration-of-excel-in-java) – jmarkmurphy Jan 04 '17 at 19:16

1 Answers1

0

Very simple:

Workbook workbook = new HSSFWorkbook(); // or: new XSSFWorkbook() - depending on excel version

Sheet sheet = workbook.getSheetAt(i);
Row row = sheet.getRow(j);

Iterator iterator = row.cellIterator();

while(iterator.hasNext()){
     Cell cell = (Cell)iterator.next();

     // do whatever with cell...
}
IntelliData
  • 441
  • 6
  • 29
  • What's that j value. You want me to specify j value as 0 to get the first row cell values – DIVA Jan 04 '17 at 16:48
  • in Java, index values are usually denoted uding i,j etc. It's only a convention. – IntelliData Jan 04 '17 at 16:48
  • 1
    Judging from your questions, I would respectfully suggest that you brush up on your basic Java skills, it might go a long way! :) – IntelliData Jan 04 '17 at 16:50
  • 1
    There are better answers for this in the duplicate question, or by looking at the apache POI quick guide https://poi.apache.org/spreadsheet/quick-guide.html#Iterator – jmarkmurphy Jan 04 '17 at 19:18