给你个方法 :
private String[] getRow(HSSFRow row) throws Exception {
if (row == null)
return null;
String[] sa = new String[12];
for (int i = 0; i < 12; i++) {
HSSFCell cell = row.getCell((short) i);
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
sa[i] = null;
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
sa[i] = cell.getStringCellValue();
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
sa[i] = NumberUtil.format(
new Double(cell.getNumericCellValue()),
numberFormat[i] == null ? "############"
: numberFormat[i]);
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
if (cell.getStringCellValue() != null
&& !"".equals(cell.getStringCellValue())) {
sa[i] = cell.getStringCellValue();
} else {
sa[i] = NumberUtil.format(new Double(cell
.getNumericCellValue()),
numberFormat[i] == null ? "############"
: numberFormat[i]);
}
}
}
return sa;
}