我刚刚为Excel Reader写了一个代码。但是它向我显示了错误。
CELL_TYPE_向我显示错误。据说它已贬值并划掉。我该如何解决这个问题?顺便说一句,我正在为Apache Poi使用3.17。
if (cell.getCellType() == Cell.CELL_TYPE_STRING)
return cell.getStringCellValue();
else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC ||
cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
String cellText = String.valueOf(cell.getNumericCellValue());
if (HSSFDateUtil.isCellDateFormatted(cell)) {
// format in form of M/D/YY
double d = cell.getNumericCellValue();
Calendar cal = Calendar.getInstance();
cal.setTime(HSSFDateUtil.getJavaDate(d));
cellText =
(String.valueOf(cal.get(Calendar.YEAR))).substring(2);
cellText = cal.get(Calendar.DAY_OF_MONTH) + "/" +
cal.get(Calendar.MONTH) + 1 + "/" +
cellText;
//System.out.println(cellText);
}