我需要从 Excel 文件中获取单元格数据,因为它们看起来像并撞到DataFormatter
了 Apache PO 类。除了包含日期的单元格之外,这就像一个魅力。下面是我的代码:
while (rowIterator.hasNext())
{
Row row = rowIterator.next();
StringBuilder rowDataBuilder = new StringBuilder();
int iCellCount = row.getLastCellNum();
for (int i = 0; i < iCellCount; i++)
{
Cell cell = row.getCell(i, Row.CREATE_NULL_AS_BLANK);
rowDataBuilder.append(dataFormatter.formatCellValue(cell));
rowDataBuilder.append(" | ");
}
_LOG.info("-----> row data: " + rowDataBuilder.toString());
}
例如,一个单元格包含 5/3/2013,我只得到 5/3/13。有什么解决方案吗?