目录
EasyPoi官网
EasyPoi应用
https://blog.csdn.net/justry_deng/article/details/84842111
EasyPoi test代码
https://gitee.com/lemur/easypoi-test
源码解读
EasyPoi是根据反射(动态代理)完成的。
导出代码
// 生成workbook 并导出
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, StudentVO.class, list);
创建sheet
获取所有属性
包括父类的Field
获取实体get方法
private Map<String, Method> getMethods = new HashMap<String, Method>();
把实体类的方法getXX()函数保存起来,方便获取属性值xx.getMethod().invoke来获取属性值
生成excel
思路
获取实体注解上的属性,以及实体,父类的属性,还有getXX,setXX方法,获取数据,再使用传统的创建shell方法创建文件
权限控制
@Excel注解的属性,默认false都显示数据
参考伊大大的文章
其中也是基于反射去注入这个属性,获取这个反射对象,再获取属性,属性上的注解,再获取代理,以及里面的属性,再注入isColumnHidden这个属性,nice