easyexcel 合并单元格
程序员文章站
2022-03-10 18:20:08
easyexcel合并单元格...
easyexcel 合并单元格
*********************
相关注解
ContentLoopMerge:标注在字段上
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface ContentLoopMerge {
int eachRow() default -1; //合并行
int columnExtend() default 1; //合并列
}
OnceAbsoluteMerge:标注在类上
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface OnceAbsoluteMerge {
int firstRowIndex() default -1; //初始行
int lastRowIndex() default -1; //最后一行
int firstColumnIndex() default -1; //初始列
int lastColumnIndex() default -1; //最后一列
}
*********************
示例
Test
@Data
class Book{
@ContentLoopMerge(eachRow = 2)
private Integer id;
private String name;
private Double price;
}
public class Test {
private static final String write_path="e:"+ File.separator+"java"+File.separator+"easyexcel"+File.separator+"write.xlsx";
public static void write(){
List<Book> list=new ArrayList<>();
for (int i=0;i<5;i++){
Book book=new Book();
book.setId(i);
book.setName("海贼王"+i);
book.setPrice((double)(i+10));
list.add(book);
}
EasyExcel.write(write_path,Book.class).sheet().doWrite(list);
}
public static void main(String[] args){
write();
}
}
****************
使用测试
本文地址:https://blog.csdn.net/weixin_43931625/article/details/107585082
上一篇: 面向对象程序设计——银行ATM机系统
下一篇: 业务代码与通用代码分离案例