excel4j 是封装apache poi(后续可能添加jxl包)的功能,使用注解的方式,简化代码,同时也在公司项目中使用,近期将不断完善代码,增加功能,同时修复BUG。
该项目使用gradle构建,不熟悉的同学,请查看官方文档 https://docs.gradle.org/4.4.1/userguide/userguide.html.
使用方法如下:
1. 加入依赖
可以使用 maven
或者使用 gradle
2. 在javaBean中添加注解
3. Java bean 导出 excel 代码如下:
更多案例, 请看github中的代码 class ExportHelperTest.java
Excel 导入代码如下:
附: custom
you can custom transform handler, implement CellEntityValueHandler or extend other handler class. And then you just do this:
this transformHandler is your CustomDoubleTransformHandler
this project is just started(https://github.com/TruthBean/excel4j), I am glad to see you join。
release
0.0.1-RELEASE
first version, init project
0.0.2-RELEASE
add cell entity model’s super class support。
eg:
@Sheet(name = “测试SHEET”, bigTitle = “hello excel4j”)
public class CellEntityTest extends CommonEntityTest {
@Column(name = “ShortNum”, columnValue = @ColumnValue(type = CellValueType.NUMBER))
private long shortNum;
@Column(order = 3, name = “用户名”, width = 9000)
private String userName;
@Column(order = 5, name = “时间”, columnValue = @ColumnValue(type = CellValueType.DATE))
private Date time;
@Column(order = 4, name = “金额”, columnValue = @ColumnValue(type = CellValueType.NUMBER, transformHandler = BigDecimalTransformHandler.class))
private BigDecimal decimal;
…}
public class CommonEntityTest {
get cell entity model filed value by invoke getter method
get map data from excel, get model (class) data from excel is not work, next version will handle it