日期:2014-05-18 浏览次数:21131 次
private String getCellValue(Cell c)
{
String o=null;
switch (c.getCellType()) {
case Cell.CELL_TYPE_BLANK:
o="";
break;
case Cell.CELL_TYPE_BOOLEAN:
o=String.valueOf(c.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
o=String.valueOf(c.getCellFormula());
break;
case Cell.CELL_TYPE_NUMERIC:
o=String.valueOf(c.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
o=c.getStringCellValue();
break;
default:
o=null;
break;
}
return o;
}
Workbook wb=WorkbookFactory.create(new File(path));
Sheet sheet=wb.getSheetAt(0);
Row row=null;
for(int i=1;i<=sheet.getLastRowNum();i++)
{
for(int j=row.getFirstCellNum();j<row.getLastCellNum();j++)
{
System.out.println(getCellValue(row.getCell(j)));
}
}