java如何判断execl里的单元格是否为空,不为空+1

2024-12-17 06:09:35
推荐回答(2个)
回答1:

一般都用poi 。自己百度吧。

回答2:

这样看行不行
HSSFWorkbook readWorkBook = new HSSFWorkbook(inputStream);
HSSFSheet readSheet = readWorkBook.getSheetAt(0);
HSSFRow readRow;
HSSFCell subjectNo; // 贷款贡献率号
if (readSheet.getLastRowNum() <= 0) {
FacesUtils.showInfo("对不起,您导入的excel未填值!");
return false;
}
for (int i = 1; i < readSheet.getLastRowNum() + 1; i++) {
readRow = readSheet.getRow(i);
if (readRow == null) {
continue;
}
subjectNo = readRow.getCell((short) 0);
if (subjectNo == null){

}
// 贷款贡献率号
if (subjectNo.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
FacesUtils.showInfo("第" + (i + 1) + "行:贷款贡献率号不能为空");
return false;
}
if (subjectNo.getCellType() == HSSFCell.CELL_TYPE_STRING) {
value.setSubjectNo((subjectNo.getStringCellValue().trim()));
} else if (subjectNo.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
value.setSubjectNo((subjectNo.getNumericCellValue() + ""));
} else {
FacesUtils.showInfo("第" + (i + 1) + "行:贷款贡献率号格式必须为字符或汉字");
return false;
}
看一下能够看懂不,不行再HI我,Q289462923