# simple-export **Repository Path**: dylan94/simple-export ## Basic Information - **Project Name**: simple-export - **Description**: 导出简单化 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-23 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SIMPLE-EXPORT ### 快速导出Excel ##### 配置使用 1. 引入maven包 ``` com.codingapi simple-export 0.0.1 ``` 2. 在需要导出数据的接口上面添加注解 ``` @SimpleExport( properties = { @PropertyAnnotate(value = "kid", headName = "kid"), @PropertyAnnotate(value = "name", headName = "名称"), @PropertyAnnotate(value = "state", headName = "状态") }, enumHandler = { @EnumHandlerAnnotate(name = "state", typeHandler = StateTypeHandler.class) }, excelName = "test2.xls") ``` 这样就可以直接导出数据了 #### 注解解释 1.properties参数: 配置导出返回数据格式的列名与对应表头信息 1.1 PropertyAnnotate参数: value:对应字段名 headName:对应表头名 2.enumHandler参数: 配置对应枚举转换信息 2.1 EnumHandlerAnnotate:枚举转换 name:需要转换的枚举类 typeHandler:转换枚举类需要进行的处理类 注意: 这个需要在业务项目中自行书写,但是需要实现EnumTypeHandler类,将枚举返回的值转换为对应的含义,导出就直接将字段转换为枚举含义 例如: ``` public class StateTypeHandler implements EnumTypeHandler { @Override public String getValue(String type) { if (Objects.isNull(type)) { return ""; } return OrderState.getName(ConvertTypeUtils.obj2Integer(type)); } } ``` 3.excelName:要导出的excel名称