# excel-start
**Repository Path**: practice-pine/excel-start
## Basic Information
- **Project Name**: excel-start
- **Description**: 基于POI的excel导入导出
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-12-21
- **Last Updated**: 2022-01-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# excel-start
#### 1 介绍
基于poi的excel导入和基于Jxls的excel导出的基础上进行封装,简化excel的导出和导入,只需要三步即可完成之前需要大量代码实现的功能。
#### 2 安装教程
```
com.gitee.practice-pine
excel-start
1.0
```
#### 3 使用说明
第一步 导入打包之后的pom依赖
第二步 添加配置文件

在resources文件夹下创建excel文件夹,并且在excel文件夹下创建conf文件夹和template文件夹,
conf文件夹下创建export.properties和import.properties文件,用于存储导入和导出的配置;在template文件夹下放置模板文件
第三步 调用
4 案例
导入excel
1 编写处理解析之后数据的实现类
@Slf4j
@Component
public class DefaultExcelImportEntityImpl implements IExcelImportEntity {
@Override
public List dealData(List dataList, String param) {
return dataList;
}
}
//需要实现IExcelImportEntity接口以及添加@Component注解(将本类注入IOC容器)
//可以在此处对数据进行一定的分析、汇总、存储等等,也可以直接返回
2 在import.properties文件中配置实现类的路径
import.configCode.classpath=cn.edu.lnpu.stopcarmanager.mapper.TestExcelImportEntityImpl
// import.configCode.classpath 中的configCode是前端传入的,选择不同的实现类
3 调用
@PostMapping("/import")
public void importExcel(String inParam, @RequestParam("file") MultipartFile file, HttpServletRequest request){
// 4.解析Excel
ImportExcelParamIn in = new ImportExcelParamIn();
in.setConfigCode("configCode");
ImportExcelParamOut importExcelParamOut = entity.importExcel(in , file);
log.info("解析Excel - > {}" , JSON.toJSONString(importExcelParamOut));
}
// excel解析时可以传入额外参数,一般用于条件 ( in.setMoreParam();)
// in.setConfigCode("configCode"); 中的参数和import.configCode.classpath中的configCode对应,用于选择不同的实现类
导出excel
1 编写实现类,查找那些数据,存入excel
@Slf4j
@Component
public class TestExcelExportEntityImpl implements IExcelExportEntity {
// 导出测试方法、此处的key需要和模板中的批注对应,这里是导出的重点,一定要看看模板的批注是怎么写的
@Override
public Map export(String param) {
List