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

使用poi进行excel导入

时间:2020-04-03 20:04:32      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:EDA   throw   archive   put   null   rdate   person   excel导入   min   

进行信息表导入

/*
导入档案
*/
@RequestMapping("addArchives")
public String addArchives(MultipartFile files) throws IOException {
//解析excel----->档案的集合------>批量插入
InputStream is = files.getInputStream();
//excel对象读取excel文件流
HSSFWorkbook book=new HSSFWorkbook(is);
List<Archives> alist=new ArrayList<>();
//遍历工作薄
for (int i = 0; i <book.getNumberOfSheets() ; i++) {
HSSFSheet sheet = book.getSheetAt(i);
if(sheet==null){
continue;
}
//遍历行
for (int j = 0; j <sheet.getLastRowNum() ; j++) {
HSSFRow row = sheet.getRow(j+1);
if(row!=null){
Archives arc=new Archives();
arc.setDnum(row.getCell(0).getStringCellValue());
arc.setLandline(row.getCell(1).getStringCellValue());
arc.setSchool(row.getCell(2).getStringCellValue());
arc.setZhuanye(row.getCell(3).getStringCellValue());
arc.setSosperson(row.getCell(4).getStringCellValue());
arc.setBiyedate(row.getCell(5).getDateCellValue());
arc.setZzmm(row.getCell(6).getStringCellValue());
arc.setMinzu(row.getCell(7).getStringCellValue());
arc.setXueli(row.getCell(8).getStringCellValue());
arc.setEmail(row.getCell(9).getStringCellValue());
arc.setEmpFk((int)row.getCell(10).getNumericCellValue());
arc.setRemark(row.getCell(11).getStringCellValue());
arc.setBirdate(row.getCell(12).getDateCellValue());
alist.add(arc);
}
}

使用poi进行excel导入

标签:EDA   throw   archive   put   null   rdate   person   excel导入   min   

原文地址:https://www.cnblogs.com/meani/p/12628400.html

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