Jsk*_*Jsk 5 java excel poi-hssf apache-poi
我一直在使用给出的示例代码来搜索工作表的内容:
Sheet sheet1 = wb.getSheetAt(0);
for (Row row : sheet1) {
for (Cell cell : row) {
CellReference cellRef = new CellReference(row.getRowNum(), cell.getCellNum());
System.out.print(cellRef.formatAsString());
System.out.print(" - ");
switch(cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
System.out.println(cell.getRichStringCellValue().getString());
break;
case Cell.CELL_TYPE_NUMERIC:
if(DateUtil.isCellDateFormatted(cell)) {
System.out.println(cell.getDateCellValue());
} else {
System.out.println(cell.getNumericCellValue());
}
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.println(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
System.out.println(cell.getCellFormula());
break;
default:
System.out.println();
}
}
Run Code Online (Sandbox Code Playgroud)
}
But can't find a way to properly compare the dates extracted from the sheet with a given date. I've tried using a data validation and also formatting the date to a string and including further conditional statements but nothing has worked.
seems like a relatively simple problem and necessary to but havent been able to fix it yet?
any help would be greatly appreciated!
| 归档时间: |
|
| 查看次数: |
3209 次 |
| 最近记录: |