Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading Date Values and Boolan Values from Excel Sheet.

807569Aug 12 2006 — edited Aug 14 2006
Hi,

I'm very new to POI API. I can not able to print the Date Values and Boolan Values when I read the excel sheet. I have written the following code:-
cell = row.getCell((short)colIndex);
if (cell != null) {
	System.out.println("Cell Type >>> " + cell.getCellType());
	switch (cell.getCellType()) {
		case HSSFCell.CELL_TYPE_NUMERIC :
			System.out.println("Numeric : " + cell.getNumericCellValue());
			break;
		case HSSFCell.CELL_TYPE_STRING :
			System.out.println("String  : " + cell.getStringCellValue());
			break;
		case HSSFCell.CELL_TYPE_BLANK :
			System.out.println("Blank   : " + cell.getStringCellValue());
			break;
		case HSSFCell.CELL_TYPE_BOOLEAN :
			System.out.println("Boolean : " + cell.getBooleanCellValue());
			break;
		case HSSFCell.CELL_TYPE_ERROR :
			System.out.println("Error   : " + cell.getErrorCellValue());
			break;
		case HSSFCell.CELL_TYPE_FORMULA :
			System.out.println("Formula : " + cell.getCellFormula());
			break;
		default :
			//Date
			if(HSSFDateUtil.isCellDateFormatted(cell)) {
				System.out.println("Date    : " + cell.getDateCellValue());
			}
	}
}
cell.getCellType() returns NUMERIC or FORMULA or STRING, how can I check for DATE, BOOLEAN and BLANK SPACE?

Any one can help me to solve this issue?

Thanks..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2006
Added on Aug 12 2006
1 comment
262 views