easypoi 导出时给文字加圈

使用easypoi导出excel时,需要指定的单元格里,给文字外加个圆圈,包裹住所有的文字,该如何处理呢

使用绘图对象Drawing进行实现

  • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/7770395
  • 你也可以参考下这篇文章:使用easypoi导出excel 自定义表格样式
  • 除此之外, 这篇博客: easypoi 模板导入、导出合并excel单元格功能中的 扩展其他 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 不使用模板的导出,使用@ExcelCollection可以自动合并单元格

    sheet.addMergedRegion(new Region(2,(short)0,3,(short )0));
    //跨两行占一列 ce.setCellStyle(style); HSSFCell ce1=row.createCell(1);
    //姓名 ce1.setCell

        public static void main(String[] args) throws IOException {
            export1();
        }
    
        @GetMapping("/goods")
        public static void export1() throws IOException {
            List<UserGoodsDto> userGoodsDtos = new ArrayList<>();
    
            UserGoodsDto userGoodsDto = new UserGoodsDto();
            userGoodsDto.setUserName("name1");
    
            List<UserGoods> userGoodsList = new ArrayList<>();
            UserGoods userGoods = new UserGoods();
            userGoods.setId(1);
            userGoods.setGoodsName("name0");
            userGoods.setGoodsAddress("add");
            userGoods.setCreatedTime(new Date());
    
            UserGoods userGoods2 = new UserGoods();
            userGoods2.setId(2);
            userGoods2.setGoodsName("name1");
            userGoods2.setGoodsAddress("add2");
            userGoods2.setCreatedTime(new Date());
    
            userGoodsList.add(userGoods);
            userGoodsList.add(userGoods2);
            userGoodsDto.setUserGoodsList(userGoodsList);
    
            //***
            UserGoodsDto userGoodsDto2 = new UserGoodsDto();
            userGoodsDto2.setUserName("name1");
    
            List<UserGoods> userGoodsList2 = new ArrayList<>();
            userGoodsList2.add(new UserGoods()
                    .setId(3)
                    .setGoodsName("name2")
                    .setGoodsAddress("add2")
                    .setCreatedTime(new Date()));
            userGoodsList2.add(new UserGoods()
                    .setId(4)
                    .setGoodsName("name3")
                    .setGoodsAddress("add2")
                    .setCreatedTime(new Date()));
            userGoodsDto2.setUserGoodsList(userGoodsList2);
    
            List<UserGoodsTest> userGoodsTestList = new ArrayList<>();
            userGoodsTestList.add(new UserGoodsTest()
                    .setId(4)
                    .setGoodsName("name3Test")
                    .setGoodsAddress("add2")
                    .setCreatedTime(new Date()));
            userGoodsDto2.setUserGoodsTestList(userGoodsTestList);
    
    
            userGoodsDtos.add(userGoodsDto);
            userGoodsDtos.add(userGoodsDto2);
    
            System.out.println(userGoodsDtos);
            ExportParams exportParams = new ExportParams("双十一客户下单情况", null);
    
            Workbook workbook = ExcelExportUtil.exportExcel(exportParams, UserGoodsDto.class, userGoodsDtos);
            // ExcelExportEntity excelExportEntity = new ExcelExportEntity();
            // ExcelExportUtil.exportExcel(exportParams, , userGoodsDtos);
            String fileAllPath = CommonConstants.TEMP_EXPORT_PATH + "1.xls";
            try (FileOutputStream fos = new FileOutputStream(fileAllPath);) {
                workbook.write(fos);
            } catch (IOException e) {
                throw new RRException(e.getLocalizedMessage());
            }
    
            // ExcelExportUtil.exportExcel(userGoodsDtos,UserGoodsDto.class,"测试",exportParams,response);
        }
    
    
    
    @Data
    @Accessors(chain = true)
    class UserGoodsDto {
        @Excel(name = "用户名", needMerge = true)
        private String userName;
        @ExcelCollection(name = "商品")
        private List<UserGoods> userGoodsList;
        @ExcelCollection(name = "商品2")
        private List<UserGoodsTest> userGoodsTestList;
    }
    
    @Data
    @Accessors(chain = true)
    class UserGoods {
        private Integer id;
        @Excel(name = "商品名")
        private String goodsName;
        @Excel(name = "收货地址")
        private String goodsAddress;
        @Excel(name = "下单时间", exportFormat = "yyyy-MM-dd HH:mm:ss")
        private Date createdTime;
    }
    
    @Data
    @Accessors(chain = true)
    class UserGoodsTest {
        private Integer id;
        @Excel(name = "商品名test")
        private String goodsName;
        @Excel(name = "收货地址test")
        private String goodsAddress;
        @Excel(name = "下单时间test", exportFormat = "yyyy-MM-dd HH:mm:ss")
        private Date createdTime;
    }
    

    oodsDto.class,“测试”,exportParams,response);
    }

    @Data
    @Accessors(chain = true)
    class UserGoodsDto {
    @Excel(name = “用户名”, needMerge = true)
    private String userName;
    @ExcelCollection(name = “商品”)
    private List userGoodsList;
    @ExcelCollection(name = “商品2”)
    private List userGoodsTestList;
    }

    @Data
    @Accessors(chain = true)
    class UserGoods {
    private Integer id;
    @Excel(name = “商品名”)
    private String goodsName;
    @Excel(name = “收货地址”)
    private String goodsAddress;
    @Excel(name = “下单时间”, exportFormat = “yyyy-MM-dd HH:mm:ss”)
    private Date createdTime;
    }

    @Data
    @Accessors(chain = true)
    class UserGoodsTest {
    private Integer id;
    @Excel(name = “商品名test”)
    private String goodsName;
    @Excel(name = “收货地址test”)
    private String goodsAddress;
    @Excel(name = “下单时间test”, exportFormat = “yyyy-MM-dd HH:mm:ss”)
    private Date createdTime;
    }