Created
January 16, 2011 08:48
-
-
Save koduki/781657 to your computer and use it in GitHub Desktop.
POI wrapper for scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getValue(cell:Cell):String = { | |
import Cell._ | |
import org.apache.poi.ss.usermodel.DateUtil | |
if (cell == null) { | |
"" | |
} else { | |
cell.getCellType match { | |
case CELL_TYPE_BLANK => "" | |
case CELL_TYPE_STRING => cell.getStringCellValue | |
case CELL_TYPE_NUMERIC => if (DateUtil.isCellDateFormatted(cell)) { | |
cell.getDateCellValue.getTime.toString | |
} else { | |
cell.getNumericCellValue.toString | |
} | |
case CELL_TYPE_FORMULA => cell.getNumericCellValue() | |
case CELL_TYPE_ERROR => cell.getErrorCellValue() | |
case CELL_TYPE_BOOLEAN => cell.getBooleanCellValue() | |
case _ => cell.toString | |
} | |
}.toString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment