Retrieve dates correctly from Excel files.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@507 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-20 04:43:39 +00:00
parent 2ee091e9ea
commit d85a0e1851

View File

@ -12,6 +12,7 @@ import java.util.Properties;
import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.NotImplementedException;
import org.apache.poi.common.usermodel.Hyperlink; import org.apache.poi.common.usermodel.Hyperlink;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
@ -166,7 +167,13 @@ public class ExcelImporter implements Importer {
if (cellType == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN) { if (cellType == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN) {
value = cell.getBooleanCellValue(); value = cell.getBooleanCellValue();
} else if (cellType == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC) { } else if (cellType == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC) {
value = cell.getNumericCellValue(); double d = cell.getNumericCellValue();
if (HSSFDateUtil.isCellDateFormatted(cell)) {
value = HSSFDateUtil.getJavaDate(d);
} else {
value = d;
}
} else { } else {
String text = cell.getStringCellValue().trim(); String text = cell.getStringCellValue().trim();
if (text.length() > 0) { if (text.length() > 0) {