文章18 | 阅读 21380 | 点赞0
相关注解
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
内容来源于网络,如有侵权,请联系作者删除!