poi读取数据怎么做非空判断和读取指定行

public ResponseResult uploading(MultipartFile file1) throws IOException {
String filename = file1.getOriginalFilename();
// 1.流读取文件
FileInputStream stream = new FileInputStream("C:\\Users\\admin\\Desktop\\sss\\" + filename);

// 2.通过poi解析流 得到 Excel文件对象
HSSFWorkbook workbook = new HSSFWorkbook(stream);

// 3.通过对象获取数据 得到表
HSSFSheet sheet = workbook.getSheetAt(0 );

HSSFRow row=null;

for(int i=0;sheet.getRow(i)!=null;i++){

row=sheet.getRow(i);

for(int j=0;row.getCell(j)!=null;j++){
// System.out.print(row.getCell(j).toString()+"");
if(j==1){
System.out.print(row.getCell(0).getStringCellValue());
System.out.println();
}else if (j==2){
System.out.print(row.getCell(2).getStringCellValue());
System.out.println();
}
}
}
return ResponseResult.okMsg("提交成功");
}
posted @ 2019-11-07 16:37  徽徽  阅读(470)  评论(0编辑  收藏  举报