🎨 excel 自动装配处理

This commit is contained in:
b2baccline
2020-05-28 12:31:47 +08:00
parent c6ab664c01
commit 32368690ec
3 changed files with 52 additions and 9 deletions

View File

@@ -32,19 +32,16 @@
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.6</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
</dependencies>

View File

@@ -1,8 +1,11 @@
package com.hccake.common.excel;
import com.hccake.common.excel.aop.DynamicNameAspect;
import com.hccake.common.excel.aop.ResponseExcelReturnValueHandler;
import com.hccake.common.excel.config.ExcelConfigProperties;
import com.hccake.common.excel.handler.ManySheetWriteHandler;
import com.hccake.common.excel.handler.SheetWriteHandler;
import com.hccake.common.excel.handler.SingleSheetWriteHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
@@ -34,12 +37,49 @@ public class ResponseExcelAutoConfiguration implements ApplicationContextAware,
private final List<SheetWriteHandler> sheetWriteHandlerList;
/**
* SPEL 解析处理器
* @return NameProcessor excle名称解析器
*/
@Bean
@ConditionalOnMissingBean
public NameProcessor nameProcessor() {
return new NameSpelExpressionProcessor();
}
/**
* Excle名称解析处理切面
* @param nameProcessor SPEL 解析处理器
* @return DynamicNameAspect
*/
@Bean
@ConditionalOnMissingBean
public DynamicNameAspect dynamicNameAspect(NameProcessor nameProcessor) {
return new DynamicNameAspect(nameProcessor);
}
/**
* 多sheet处理器
* @param configProperties Excle导出配置
* @return ManySheetWriteHandler
*/
@Bean
@ConditionalOnMissingBean
public ManySheetWriteHandler manySheetWriteHandler(ExcelConfigProperties configProperties) {
return new ManySheetWriteHandler(configProperties);
}
/**
* 单sheet处理器
* @param configProperties Excle导出配置
* @return SingleSheetWriteHandler
*/
@Bean
@ConditionalOnMissingBean
public SingleSheetWriteHandler singleSheetWriteHandler(ExcelConfigProperties configProperties) {
return new SingleSheetWriteHandler(configProperties);
}
@Override
public void afterPropertiesSet() {
@@ -57,5 +97,4 @@ public class ResponseExcelAutoConfiguration implements ApplicationContextAware,
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}

View File

@@ -19,6 +19,7 @@
<xxl-job.version>2.2.0</xxl-job.version>
<spring-boot-admin.version>2.2.2</spring-boot-admin.version>
<oss.aliyun.version>3.8.0</oss.aliyun.version>
<easyexcel.version>2.1.6</easyexcel.version>
</properties>
<dependencyManagement>
@@ -117,6 +118,12 @@
<artifactId>aliyun-sdk-oss</artifactId>
<version>${oss.aliyun.version}</version>
</dependency>
<!--easyExcel 处理-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
</dependency>
<!--监控server端-->
<dependency>
<groupId>de.codecentric</groupId>