import java.io.File;
import java.io.FileInputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class Prueba {
private ArrayList<String> listaDni = new ArrayList<String>();
public ArrayList<String> getListaDni() {
return listaDni;
}
public Prueba(File fileName) throws ParseException{
List cellDataList = new ArrayList();
try{
FileInputStream fileInputStream = new FileInputStream( fileName);
XSSFWorkbook workBook = new XSSFWorkbook(fileInputStream);
XSSFSheet hssfSheet = workBook.getSheetAt(0);
Iterator rowIterator = hssfSheet.rowIterator();
while (rowIterator.hasNext()){
XSSFRow hssfRow = (XSSFRow) rowIterator.next();
Iterator iterator = hssfRow.cellIterator();
List cellTempList = new ArrayList();
while (iterator.hasNext()){
XSSFCell hssfCell = (XSSFCell) iterator.next();
cellTempList.add(hssfCell);
}
cellDataList.add(cellTempList);
}
}catch (Exception e)
{e.printStackTrace();}
Leer(cellDataList);
}
private void Leer(List cellDataList){
for (int i = 0; i < cellDataList.size(); i++){
List cellTempList = (List) cellDataList.get(i);
for (int j = 0; j < cellTempList.size(); j++){
XSSFCell hssfCell = (XSSFCell) cellTempList.get(j);
String stringCellValue = hssfCell.toString();
System.out.print(stringCellValue+" ");
if(j==3){
listaDni.add(stringCellValue);
}
}
System.out.println();
}
}
}
import java.io.FileInputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class Prueba {
private ArrayList<String> listaDni = new ArrayList<String>();
public ArrayList<String> getListaDni() {
return listaDni;
}
public Prueba(File fileName) throws ParseException{
List cellDataList = new ArrayList();
try{
FileInputStream fileInputStream = new FileInputStream( fileName);
XSSFWorkbook workBook = new XSSFWorkbook(fileInputStream);
XSSFSheet hssfSheet = workBook.getSheetAt(0);
Iterator rowIterator = hssfSheet.rowIterator();
while (rowIterator.hasNext()){
XSSFRow hssfRow = (XSSFRow) rowIterator.next();
Iterator iterator = hssfRow.cellIterator();
List cellTempList = new ArrayList();
while (iterator.hasNext()){
XSSFCell hssfCell = (XSSFCell) iterator.next();
cellTempList.add(hssfCell);
}
cellDataList.add(cellTempList);
}
}catch (Exception e)
{e.printStackTrace();}
Leer(cellDataList);
}
private void Leer(List cellDataList){
for (int i = 0; i < cellDataList.size(); i++){
List cellTempList = (List) cellDataList.get(i);
for (int j = 0; j < cellTempList.size(); j++){
XSSFCell hssfCell = (XSSFCell) cellTempList.get(j);
String stringCellValue = hssfCell.toString();
System.out.print(stringCellValue+" ");
if(j==3){
listaDni.add(stringCellValue);
}
}
System.out.println();
}
}
}