答案 0 :(得分:2)
FileInputStream file = new FileInputStream(new File("C:\\test.xls"));
//Get the workbook instance for XLS file
HSSFWorkbook workbook = new HSSFWorkbook(file);
//Get third(numbering starts from 0) sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(2);
//Get iterator to all the rows in current sheet
Iterator<Row> rowIterator = sheet.iterator();
// Iterate through rows
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
// Index of column D is 3 (A->0, B->1, etc)
Cell cellD = row.getCell(3);
Cell cellF = row.getCell(5);
Date dateD = HSSFDateUtil.getJavaDate(cellD.getNumberValue());
Date dateF = HSSFDateUtil.getJavaDate(cellF.getNumberValue());
// Your business logic continues....
}