- 最近造了个poi导出 excel轮子
- 特点
- java bean 一对多、多对一关系合并单元行
- 支持图片导出
Bean 一对多关系合并行
public class User { @Excel(name = "编号") private String serialNumber; @Excel(name = "国籍") private String citizenship; @Excel(name = "省份") private String province; @Excel(name = "城市") private String city; @Excel(name = "市区") private String area; /** * 一对多合并注解 */ @ExcelCollection private List userInfoList;}public class UserInfo { @Excel(name = "头像") private String avatar; @Excel(name = "用户名") private String name; @Excel(name = "年龄") private Integer age; @Excel(name = "性别") private Integer sex;}
Bean 多对一关系合并行
public class ManyOneBean { @ExcelCollection private List manyOne;}public class ManyOne { @Excel(name = "产品名称") private String productName; @Excel(name = "品牌名称") private String breanName; @Excel(name = "金额") private Integer amount; @Excel(name = "产品原单价", manyOneMerge = true) private String originalUnitPrice; @Excel(name = "优惠单价", manyOneMerge = true) private String discountUnitPrice; @Excel(name = "总金额", manyOneMerge = true) private Integer totalAmount;}
- 关键是ExcelCollection注解以及Excel注解中的manyOneMerge设置值
最后
- 轮子初步实现以上功能,仅供自己玩耍。后续继续完善,奥力给