XSSF read
public void readXSSF() {
InputStream in = null;
try {
File sourceFile = new File("c:/sample.xls");
in = new FileInputStream(sourceFile);
Workbook wb = WorkbookFactory.create(in);
Sheet sheet = wb.getSheetAt(0);
for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext(); ) {
Row row = rit.next();
for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext(); ) {
Cell cell = cit.next();
System.out.print(cell + "\t");
}
System.out.println();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
} finally {
try {
if (in != null) in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}