Java 读取excel创建excel通过 cn.hutool.poi.excel包

        Path execl1 = Paths.get("/训练数据录音流水号.xlsx");

        List<Map<String, Object>> list = new ArrayList<>();
        ExcelReader reader = ExcelUtil.getReader(execl1.toString());
        Sheet sheet = reader.getSheets().get(0);
        Iterator<Row> it = sheet.rowIterator();
        it.next();
        int n = 0;
        while (it.hasNext() && n < 10) {
            Map<String, Object> map = new HashMap<>();
            Row next = it.next();
            String index0 = next.getCell(0).getStringCellValue();
            String index1 = next.getCell(1).getStringCellValue();
            String index2 = next.getCell(2).getStringCellValue();
            String index3 = next.getCell(3).getStringCellValue();
            String index4 = next.getCell(4).getStringCellValue();
            map.put("录音流水号", index0);
            map.put("接触号", index1);
            map.put("文本内容", index2);
            map.put("关联标签", index3);
            map.put("内容", index4);
            list.add(map);
            n++;
        }
        String tempPath = "/IdUtil.fastSimpleUUID() + ".xlsx";
        File file = new File(tempPath);
        BigExcelWriter writer = ExcelUtil.getBigWriter(file);
        writer.write(list, true);
        writer.flush();

posted @ 2023-03-14 11:16  lambertlt  阅读(112)  评论(0编辑  收藏  举报