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);
    }
    }

  • 相关阅读:
    Java 构造方法总结
    Intellij IDEA使用总结
    阿里巴巴Java开发手册
    灰度发布策略
    php redis 命令合集
    php redis 常用方法
    php excel 设置单元格格式为文本格式
    php curl get post 方法的封装
    PHP 判断手机号归属地 和 运营商的免费接口
    lnmp centos7 memcache服务器端 和 memcache memcached扩展的安装
  • 原文地址:https://www.cnblogs.com/meani/p/12628400.html
Copyright © 2011-2022 走看看