码迷,mamicode.com
首页 > 其他好文 > 详细

poi读取数据和过滤空值 和指定列打印

时间:2019-11-07 19:35:06      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:lse   数据   des   multi   ring   throws   cell   nal   gets   

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("提交成功");
}

poi读取数据和过滤空值 和指定列打印

标签:lse   数据   des   multi   ring   throws   cell   nal   gets   

原文地址:https://www.cnblogs.com/zhaohuihui/p/11814100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!