文章18 | 阅读 21386 | 点赞0
示例
Test
@Data
class Product{
private Integer id;
private String name;
private Double price;
private String desc;
}
public class Test {
private static final String template_path="e:"+ File.separator+"java"+File.separator+"easyexcel"+File.separator+"template.xlsx";
private static final String fill_path="e:"+ File.separator+"java"+File.separator+"easyexcel"+File.separator+"fill.xlsx";
private static final String fill_path2="e:"+ File.separator+"java"+File.separator+"easyexcel"+File.separator+"fill2.xlsx";
public static void fill(){
Product product=new Product();
product.setId(1);
product.setName("apple");
product.setPrice(10d);
EasyExcel.write(fill_path,Product.class).withTemplate(template_path).sheet().doFill(product);
}
public static void fill2(){
Map<String,Object> map=new HashMap<>();
map.put("id",1);
map.put("name","banana");
map.put("price",6);
EasyExcel.write(fill_path2).withTemplate(template_path).sheet().doFill(map);
}
public static void main(String[] args){
fill();
fill2();
}
}
使用测试
填充模板
fill
fill2
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/weixin_43931625/article/details/107618917
内容来源于网络,如有侵权,请联系作者删除!