zoukankan      html  css  js  c++  java
  • 使用poi进行excel导入

    进行信息表导入

    /*
    导入档案
    */
    @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);
    }
    }

  • 相关阅读:
    JFinal框架
    shiro认证登录实现
    linux常用的命令
    zookeeper部署到linux操作步骤
    java的冒泡排序
    软件设计的七大原则
    vue知识点整理
    JVM垃圾回收算法
    Sql Server删库了怎么办?跑路是不可能跑路的
    Linux--find用法
  • 原文地址:https://www.cnblogs.com/meani/p/12628400.html
Copyright © 2011-2022 走看看