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);
SystemParam system=new SystemParam();
for(int j=0;row.getCell(j)!=null;j++){
// System.out.print(row.getCell(j).toString()+"");

if(j==0){
// System.out.print(row.getCell(0).getStringCellValue());
// System.out.println();
system.setName(row.getCell(0).getStringCellValue());
}else if (j==2){
system.setValues("lv_"+row.getCell(2).getStringCellValue());
// System.out.print("lv_"+row.getCell(2).getStringCellValue());
// System.out.println();
}

}
System.out.println(system);
}
return ResponseResult.okMsg("提交成功");
}

猜你喜欢

转载自www.cnblogs.com/zhaohuihui/p/11818366.html
今日推荐