easyexcel 简单填充
********************
示例
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