poi导入excel表格 ,老版本excel用HSSFWorkbook 新版本用XSSFWorkbook

        File excelFile = new File("v:\\工作簿1.xlsx");
        XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(excelFile));
        XSSFSheet sheet = wb.getSheetAt(0);
        System.out.println(sheet.getLastRowNum());


        for (Row row : sheet) {
            System.out.println("-------");
            if (row.getCell(0).toString() == null)
                break;
            stringRedisTemplate.opsForValue().set(row.getCell(0).toString(),"0"+row.getCell(1).toString());
        }
posted @ 2021-10-19 09:50  super_胡  阅读(358)  评论(0编辑  收藏  举报