注意:
当前测试基于lombok和junit环境
新建Model
import cn.zzhardy.annotation.Excel;
import lombok.Setter;
public class Example {
@Setter
@Excel(name = "表格标题一", sort = 1)
private String titleOne;
@Setter
@Excel(name = "表格标题二", sort = 2)
private String titleTwo;
@Setter
@Excel(name = "表格标题三", sort = 1)
private String titleThree;
}
新建测试类数据
@Test
public void excelTest() {
List<Example> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Example example = new Example();
example.setTitleOne("标题一 - " + i);
example.setTitleTwo("标题二 - " + i);
example.setTitleThree("标题三 - " + i);
list.add(example);
}
ExcelCenter<Example> util = new ExcelCenter<>(Example.class);
util.exportExcel(list, "Excel生成案例");
}
效果图
![第一个测试用例.png](/uploads/projects/qianmozhizhong@gchrkp/ea60f7bfe0ae63643d078c3fa8b2b176.png)