Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: easyexcel切换fastexcel #494

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/asciidoctor/spring-extension-subassembly.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ include::{basedir}/disruptor.adoc[]

include::{basedir}/dynamic.adoc[]

include::{basedir}/easyexcel.adoc[]
include::{basedir}/fastexcel.adoc[]

include::{basedir}/http.adoc[]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[[easyexcel]]
==== easyexcel
[[fastexcel]]
==== fastexcel

===== Excel导入

使用注解 `@ExcelImport` 解析Excel(支持Spring Webflux) +
fileName指定文件名称 +
parse使用自定义封装阿里EasyExcel的解析器 `com.livk.excel.mvc.listener.InfoExcelListener` +
parse使用自定义封装FastExcel的解析器 `com.livk.excel.mvc.listener.InfoExcelListener` +
paramName指定需要传递至那个参数 +

[source,java,indent=0]
Expand Down Expand Up @@ -85,9 +85,9 @@ public class Info2Controller {
}
----

===== easyexcel-spring-boot-starter
===== fastexcel-spring-boot-starter

artifactId: easyexcel-spring-boot-starter
artifactId: fastexcel-spring-boot-starter

根据Servlet环境自动注册 *ExcelMethodArgumentResolver* 和 *ExcelMethodReturnValueHandler* +

Expand Down
16 changes: 8 additions & 8 deletions docs/spring-boot-extension-1.4.1-SNAPSHOT.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>spring boot extension doc</h1>
<div class="details">
<span id="author" class="author">Livk</span><br>
<span id="revnumber">version 1.4.1-SNAPSHOT,</span>
<span id="revdate">2024-12-09</span>
<span id="revdate">2024-12-10</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
Expand Down Expand Up @@ -129,11 +129,11 @@ <h1>spring boot extension doc</h1>
<li><a href="#_dynamic_datasource_boot_starter">dynamic-datasource-boot-starter</a></li>
</ul>
</li>
<li><a href="#easyexcel">3.3.4. easyexcel</a>
<li><a href="#fastexcel">3.3.4. fastexcel</a>
<ul class="sectlevel4">
<li><a href="#_excel导入">Excel导入</a></li>
<li><a href="#_excel导出">Excel导出</a></li>
<li><a href="#_easyexcel_spring_boot_starter">easyexcel-spring-boot-starter</a></li>
<li><a href="#_fastexcel_spring_boot_starter">fastexcel-spring-boot-starter</a></li>
</ul>
</li>
<li><a href="#http-spring-boot-starter">3.3.5. http-spring-boot-starter</a></li>
Expand Down Expand Up @@ -1223,13 +1223,13 @@ <h5 id="_dynamic_datasource_boot_starter"><a class="anchor"
</div>
</div>
<div class="sect3">
<h4 id="easyexcel"><a class="anchor" href="#easyexcel"></a>3.3.4. easyexcel</h4>
<h4 id="fastexcel"><a class="anchor" href="#fastexcel"></a>3.3.4. fastexcel</h4>
<div class="sect4">
<h5 id="_excel导入"><a class="anchor" href="#_excel导入"></a>Excel导入</h5>
<div class="paragraph">
<p>使用注解 <code>@ExcelImport</code> 解析Excel(支持Spring Webflux)<br>
fileName指定文件名称<br>
parse使用自定义封装阿里EasyExcel的解析器
parse使用自定义封装FastExcel的解析器
<code>com.livk.excel.mvc.listener.InfoExcelListener</code><br>
paramName指定需要传递至那个参数<br></p>
</div>
Expand Down Expand Up @@ -1321,10 +1321,10 @@ <h5 id="_excel导出"><a class="anchor" href="#_excel导出"></a>Excel导出</h5
</div>
</div>
<div class="sect4">
<h5 id="_easyexcel_spring_boot_starter"><a class="anchor" href="#_easyexcel_spring_boot_starter"></a>easyexcel-spring-boot-starter
<h5 id="_fastexcel_spring_boot_starter"><a class="anchor" href="#_fastexcel_spring_boot_starter"></a>fastexcel-spring-boot-starter
</h5>
<div class="paragraph">
<p>artifactId: easyexcel-spring-boot-starter</p>
<p>artifactId: fastexcel-spring-boot-starter</p>
</div>
<div class="paragraph">
<p>根据Servlet环境自动注册 <strong>ExcelMethodArgumentResolver</strong> 和 <strong>ExcelMethodReturnValueHandler</strong><br>
Expand Down Expand Up @@ -1678,7 +1678,7 @@ <h2 id="_问题"><a class="anchor" href="#_问题"></a>4. 问题</h2>
<div id="footer">
<div id="footer-text">
Version 1.4.1-SNAPSHOT<br>
Last updated 2024-12-09 17:26:42 +0800
Last updated 2024-12-10 +0800
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mybatis = "3.5.17"
mybatis-spring = "3.0.4"
mybatis-boot = "3.0.4"
guava = "33.3.1-jre"
easyexcel = "4.0.3"
fastexcel = "1.0.0"
redisson = "3.40.1"
clickhouse = "0.7.1"
spotbugs-annotations = "4.8.6"
Expand Down Expand Up @@ -71,7 +71,7 @@ mapstruct-processor = { group = "org.mapstruct", name = "mapstruct-processor", v
lombok-mapstruct = { group = "org.projectlombok", name = "lombok-mapstruct-binding", version.ref = "mapstruct-lombok" }

guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
easyexcel = { group = "com.alibaba", name = "easyexcel", version.ref = "easyexcel" }
fastexcel = { group = "cn.idev.excel", name = "fastexcel", version.ref = "fastexcel" }
spotbugs-annotations = { group = "com.github.spotbugs", name = "spotbugs-annotations", version.ref = "spotbugs-annotations" }
curator-recipes = { group = "org.apache.curator", name = "curator-recipes", version.ref = "curator" }
browscap-java = { group = "com.blueconic", name = "browscap-java", version.ref = "browscap-java" }
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-example/example.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ link:spring-clickhouse/spring-clickhouse-jdbc[Spring整合ClickHouse-jdbc] +
link:spring-clickhouse/spring-clickhouse-r2dbc[Spring整合ClickHouse-r2dbc] +
link:spring-doc/spring-doc-mvc[spring mvc整合Spring doc] +
link:spring-doc/spring-doc-webflux[spring webflux整合spring doc] +
link:spring-easyexcel/spring-easyexcel-batch[spring batch整合Excel自定义注解实现导入和导出] +
link:spring-fastexcel/spring-fastexcel-batch[spring batch整合Excel自定义注解实现导入和导出] +
link:spring-graphql/spring-graphql-mybatis[graphql整合Mybatis] +
link:spring-graphql/spring-graphql-r2dbc[graphql整合Postgres R2dbc] +
link:spring-hateoas[spring整合hateoas实现restful风格返回] +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
implementation(project(":spring-boot-extension-starters:easyexcel-spring-boot-starter"))
implementation(project(":spring-boot-extension-starters:fastexcel-spring-boot-starter"))
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-batch")
implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package com.livk.excel.batch.controller;

import com.google.common.collect.Lists;
import com.livk.context.easyexcel.annotation.ExcelParam;
import com.livk.context.easyexcel.annotation.RequestExcel;
import com.livk.context.easyexcel.listener.TypeExcelMapReadListener;
import com.livk.context.fastexcel.annotation.ExcelParam;
import com.livk.context.fastexcel.annotation.RequestExcel;
import com.livk.context.fastexcel.listener.TypeExcelMapReadListener;
import com.livk.excel.batch.entity.Info;
import com.livk.excel.batch.listener.InfoExcelListener;
import com.livk.excel.batch.listener.JobListener;
import com.livk.excel.batch.support.EasyExcelItemReader;
import com.livk.excel.batch.support.FastExcelItemReader;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
Expand Down Expand Up @@ -83,7 +83,7 @@ public HttpEntity<Void> upload(@ExcelParam List<Info> dataExcels) throws JobInst

@PostMapping("excel")
public HttpEntity<List<Info>> up(@RequestParam("file") MultipartFile file) throws IOException {
EasyExcelItemReader<Info> itemReader = new EasyExcelItemReader<>(file.getInputStream(),
FastExcelItemReader<Info> itemReader = new FastExcelItemReader<>(file.getInputStream(),
new TypeExcelMapReadListener<>() {
});
List<Info> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.livk.excel.batch.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.livk.excel.batch.listener;

import com.livk.context.easyexcel.listener.TypeExcelMapReadListener;
import com.livk.context.fastexcel.listener.TypeExcelMapReadListener;
import com.livk.excel.batch.entity.Info;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,27 @@

package com.livk.excel.batch.support;

import cn.idev.excel.FastExcel;
import com.livk.context.fastexcel.listener.ExcelMapReadListener;
import org.springframework.batch.item.ItemReader;
import org.springframework.core.GenericTypeResolver;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.excel.EasyExcel;
import com.livk.context.easyexcel.listener.ExcelMapReadListener;

import org.springframework.batch.item.ItemReader;
import org.springframework.core.GenericTypeResolver;

/**
* <p>
* EasyExcelItemReader
* </p>
*
* @author livk
*/
public class EasyExcelItemReader<T> implements ItemReader<T> {
public class FastExcelItemReader<T> implements ItemReader<T> {

private final List<T> data;

public EasyExcelItemReader(InputStream inputStream, ExcelMapReadListener<T> excelReadListener) {
public FastExcelItemReader(InputStream inputStream, ExcelMapReadListener<T> excelReadListener) {
@SuppressWarnings("unchecked")
Class<T> targetClass = (Class<T>) GenericTypeResolver.resolveTypeArgument(excelReadListener.getClass(),
ExcelMapReadListener.class);
EasyExcel.read(inputStream, targetClass, excelReadListener).sheet().doRead();
FastExcel.read(inputStream, targetClass, excelReadListener).sheet().doRead();
data = new ArrayList<>(excelReadListener.getCollectionData());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
optional("org.springframework:spring-jdbc")
optional("jakarta.servlet:jakarta.servlet-api")
optional("jakarta.validation:jakarta.validation-api")
optional("com.alibaba:easyexcel")
optional("cn.idev.excel:fastexcel")
optional("org.springframework:spring-webmvc")
optional("org.springframework:spring-webflux")
optional("org.redisson:redisson")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

package com.livk.autoconfigure.easyexcel;
package com.livk.autoconfigure.fastexcel;

import com.alibaba.excel.EasyExcel;
import cn.idev.excel.FastExcel;
import com.livk.auto.service.annotation.SpringAutoService;
import com.livk.context.easyexcel.resolver.ExcelMethodArgumentResolver;
import com.livk.context.easyexcel.resolver.ExcelMethodReturnValueHandler;
import com.livk.context.easyexcel.resolver.ReactiveExcelMethodArgumentResolver;
import com.livk.context.easyexcel.resolver.ReactiveExcelMethodReturnValueHandler;
import com.livk.context.fastexcel.resolver.ExcelMethodArgumentResolver;
import com.livk.context.fastexcel.resolver.ExcelMethodReturnValueHandler;
import com.livk.context.fastexcel.resolver.ReactiveExcelMethodArgumentResolver;
import com.livk.context.fastexcel.resolver.ReactiveExcelMethodReturnValueHandler;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
Expand All @@ -43,7 +43,7 @@
*/
@AutoConfiguration
@SpringAutoService
@ConditionalOnClass(EasyExcel.class)
@ConditionalOnClass(FastExcel.class)
public class ExcelAutoConfiguration {

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description = "fastexcel spring boot starter"

dependencies {
api("cn.idev.excel:fastexcel") {
exclude(group = "com.sun.xml.bind", module = "jaxb-core")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ plugins {
}

dependencies {
implementation(project(":spring-boot-extension-starters:easyexcel-spring-boot-starter"))
implementation(project(":spring-boot-extension-starters:fastexcel-spring-boot-starter"))
implementation("org.springframework.boot:spring-boot-starter-webflux")
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.livk.excel.reactive.controller;

import com.livk.context.easyexcel.annotation.ExcelController;
import com.livk.context.easyexcel.annotation.ExcelParam;
import com.livk.context.easyexcel.annotation.RequestExcel;
import com.livk.context.fastexcel.annotation.ExcelController;
import com.livk.context.fastexcel.annotation.ExcelParam;
import com.livk.context.fastexcel.annotation.RequestExcel;
import com.livk.excel.reactive.entity.Info;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.livk.excel.reactive.controller;

import com.livk.context.easyexcel.annotation.ExcelParam;
import com.livk.context.easyexcel.annotation.RequestExcel;
import com.livk.context.easyexcel.annotation.ResponseExcel;
import com.livk.context.fastexcel.annotation.ExcelParam;
import com.livk.context.fastexcel.annotation.RequestExcel;
import com.livk.context.fastexcel.annotation.ResponseExcel;
import com.livk.excel.reactive.entity.Info;
import com.livk.excel.reactive.listener.InfoExcelListener;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.livk.excel.reactive.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.livk.excel.reactive.listener;

import com.livk.context.easyexcel.listener.TypeExcelMapReadListener;
import com.livk.context.fastexcel.listener.TypeExcelMapReadListener;
import com.livk.excel.reactive.entity.Info;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.livk.excel.reactive.controller;

import com.livk.commons.io.FileUtils;
import com.livk.context.easyexcel.annotation.ResponseExcel;
import com.livk.context.fastexcel.annotation.ResponseExcel;
import com.livk.excel.reactive.entity.Info;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.livk.commons.io.FileUtils;
import com.livk.context.easyexcel.annotation.ResponseExcel;
import com.livk.context.fastexcel.annotation.ResponseExcel;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
implementation(project(":spring-boot-extension-starters:easyexcel-spring-boot-starter"))
implementation(project(":spring-boot-extension-starters:fastexcel-spring-boot-starter"))
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter")
implementation("com.mysql:mysql-connector-j")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.livk.excel.mvc.controller;

import com.livk.context.easyexcel.annotation.ExcelController;
import com.livk.context.easyexcel.annotation.ExcelParam;
import com.livk.context.easyexcel.annotation.RequestExcel;
import com.livk.context.fastexcel.annotation.ExcelController;
import com.livk.context.fastexcel.annotation.ExcelParam;
import com.livk.context.fastexcel.annotation.RequestExcel;
import com.livk.excel.mvc.entity.Info;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.livk.excel.mvc.controller;

import com.google.common.collect.Lists;
import com.livk.context.easyexcel.annotation.ExcelParam;
import com.livk.context.easyexcel.annotation.RequestExcel;
import com.livk.context.easyexcel.annotation.ResponseExcel;
import com.livk.context.fastexcel.annotation.ExcelParam;
import com.livk.context.fastexcel.annotation.RequestExcel;
import com.livk.context.fastexcel.annotation.ResponseExcel;
import com.livk.excel.mvc.entity.Info;
import com.livk.excel.mvc.listener.InfoExcelListener;
import com.livk.excel.mvc.service.InfoService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.livk.excel.mvc.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Loading
Loading