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

♻️ 适配 fastexcel, @RequestExcel注解支持读取excel前多少行. #320

Merged
merged 1 commit into from
Dec 11, 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
12 changes: 6 additions & 6 deletions ballcat-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<!-- 依赖版本 -->
<alipay-sdk.version>4.11.28.ALL</alipay-sdk.version>
<easyexcel.version>4.0.1</easyexcel.version>
<fastexcel.version>1.0.0</fastexcel.version>
<fastjson.version>1.2.83</fastjson.version>
<hutool.version>5.8.16</hutool.version>
<io.swagger.v3.version>2.2.7</io.swagger.v3.version>
Expand Down Expand Up @@ -104,11 +104,11 @@
<scope>import</scope>
</dependency>
<!-- ======================= 第三方依赖 ===================== -->
<!--easyExcel 处理-->
<!-- fast excel-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
<version>${fastexcel.version}</version>
</dependency>
<!-- fastjson -->
<dependency>
Expand Down Expand Up @@ -337,7 +337,7 @@
<!-- excel -->
<dependency>
<groupId>org.ballcat</groupId>
<artifactId>ballcat-spring-boot-starter-easyexcel</artifactId>
<artifactId>ballcat-spring-boot-starter-fastexcel</artifactId>
<version>${revision}</version>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion ballcat-parent/src/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="org.bson.types.ObjectId" checks="[a-zA-Z0-9]*" />
<suppress files="com.alibaba.excel.*.*\.java" checks="[a-zA-Z0-9]*" />
<suppress files="cn.idev.excel.*.*\.java" checks="[a-zA-Z0-9]*" />

<suppress files="org.ballcat.*.*TestApplication" checks="HideUtilityClassConstructorCheck" />
<suppress files="org.ballcat.pay.wx.domain.DefaultWxDomain" checks="FinalClassCheck" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<relativePath>../../ballcat-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ballcat-spring-boot-starter-easyexcel</artifactId>
<artifactId>ballcat-spring-boot-starter-fastexcel</artifactId>

<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.alibaba.excel.read.processor;
package cn.idev.excel.read.processor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.enums.HeadKindEnum;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelAnalysisStopException;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty;
import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.excel.util.StringUtils;
import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.enums.HeadKindEnum;
import cn.idev.excel.enums.RowTypeEnum;
import cn.idev.excel.exception.ExcelAnalysisException;
import cn.idev.excel.exception.ExcelAnalysisStopException;
import cn.idev.excel.metadata.Head;
import cn.idev.excel.metadata.data.ReadCellData;
import cn.idev.excel.read.listener.ReadListener;
import cn.idev.excel.read.metadata.holder.ReadRowHolder;
import cn.idev.excel.read.metadata.property.ExcelReadHeadProperty;
import cn.idev.excel.util.ConverterUtils;
import cn.idev.excel.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.alibaba.excel.util;
package cn.idev.excel.util;

import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ConverterKeyBuild;
import com.alibaba.excel.converters.ConverterKeyBuild.ConverterKey;
import com.alibaba.excel.converters.NullableObjectConverter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
import org.ballcat.easyexcel.util.EasyExcelUtils;
import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.converters.Converter;
import cn.idev.excel.converters.ConverterKeyBuild;
import cn.idev.excel.converters.ConverterKeyBuild.ConverterKey;
import cn.idev.excel.converters.NullableObjectConverter;
import cn.idev.excel.converters.ReadConverterContext;
import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.exception.ExcelDataConvertException;
import cn.idev.excel.metadata.data.CellData;
import cn.idev.excel.metadata.data.ReadCellData;
import cn.idev.excel.metadata.property.ExcelContentProperty;
import cn.idev.excel.read.metadata.holder.ReadSheetHolder;
import org.ballcat.fastexcel.util.FastExcelUtils;

/**
* Converting objects
Expand Down Expand Up @@ -140,7 +140,7 @@ private static Object doConvertToJavaObject(ReadCellData<?> cellData, Class<?> c

if (converter == null) {
ConverterKey key = ConverterKeyBuild.buildKey(clazz, cellData.getType());
converter = EasyExcelUtils.find(key, converterMap);
converter = FastExcelUtils.find(key, converterMap);
}

if (converter == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package com.alibaba.excel.write.executor;
package cn.idev.excel.write.executor;

import java.util.List;

import com.alibaba.excel.context.WriteContext;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ConverterKeyBuild;
import com.alibaba.excel.converters.NullableObjectConverter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.exception.ExcelWriteDataConvertException;
import com.alibaba.excel.metadata.data.CommentData;
import com.alibaba.excel.metadata.data.FormulaData;
import com.alibaba.excel.metadata.data.HyperlinkData;
import com.alibaba.excel.metadata.data.ImageData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.util.DateUtils;
import com.alibaba.excel.util.FileTypeUtils;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.util.StyleUtil;
import com.alibaba.excel.util.WorkBookUtil;
import com.alibaba.excel.util.WriteHandlerUtils;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;
import cn.idev.excel.context.WriteContext;
import cn.idev.excel.converters.Converter;
import cn.idev.excel.converters.ConverterKeyBuild;
import cn.idev.excel.converters.NullableObjectConverter;
import cn.idev.excel.converters.WriteConverterContext;
import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.exception.ExcelWriteDataConvertException;
import cn.idev.excel.metadata.data.CommentData;
import cn.idev.excel.metadata.data.FormulaData;
import cn.idev.excel.metadata.data.HyperlinkData;
import cn.idev.excel.metadata.data.ImageData;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.metadata.property.ExcelContentProperty;
import cn.idev.excel.support.ExcelTypeEnum;
import cn.idev.excel.util.DateUtils;
import cn.idev.excel.util.FileTypeUtils;
import cn.idev.excel.util.ListUtils;
import cn.idev.excel.util.StyleUtil;
import cn.idev.excel.util.WorkBookUtil;
import cn.idev.excel.util.WriteHandlerUtils;
import cn.idev.excel.write.handler.context.CellWriteHandlerContext;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.ss.usermodel.Cell;
Expand All @@ -34,7 +34,7 @@
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.ballcat.easyexcel.util.EasyExcelUtils;
import org.ballcat.fastexcel.util.FastExcelUtils;

/**
* Excel write Executor
Expand Down Expand Up @@ -312,7 +312,7 @@ private WriteCellData<?> doConvert(CellWriteHandlerContext cellWriteHandlerConte
}
ConverterKeyBuild.ConverterKey key = ConverterKeyBuild.buildKey(
cellWriteHandlerContext.getOriginalFieldClass(), cellWriteHandlerContext.getTargetCellDataType());
converter = EasyExcelUtils.find(key, writeContext.currentWriteHolder().converterMap());
converter = FastExcelUtils.find(key, writeContext.currentWriteHolder().converterMap());
}
if (cellWriteHandlerContext.getOriginalValue() == null && !(converter instanceof NullableObjectConverter)) {
return new WriteCellData<>(CellDataTypeEnum.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
* limitations under the License.
*/

package org.ballcat.easyexcel;
package org.ballcat.fastexcel;

import java.util.List;

import javax.validation.Validator;

import com.alibaba.excel.converters.Converter;
import cn.idev.excel.converters.Converter;
import lombok.RequiredArgsConstructor;
import org.ballcat.easyexcel.aop.ResponseExcelReturnValueHandler;
import org.ballcat.easyexcel.config.ExcelConfigProperties;
import org.ballcat.easyexcel.enhance.DefaultWriterBuilderEnhancer;
import org.ballcat.easyexcel.enhance.WriterBuilderEnhancer;
import org.ballcat.easyexcel.handler.ManySheetWriteHandler;
import org.ballcat.easyexcel.handler.SheetWriteHandler;
import org.ballcat.easyexcel.handler.SingleSheetWriteHandler;
import org.ballcat.easyexcel.head.I18nHeaderCellWriteHandler;
import org.ballcat.fastexcel.aop.ResponseExcelReturnValueHandler;
import org.ballcat.fastexcel.config.ExcelConfigProperties;
import org.ballcat.fastexcel.enhance.DefaultWriterBuilderEnhancer;
import org.ballcat.fastexcel.enhance.WriterBuilderEnhancer;
import org.ballcat.fastexcel.handler.ManySheetWriteHandler;
import org.ballcat.fastexcel.handler.SheetWriteHandler;
import org.ballcat.fastexcel.handler.SingleSheetWriteHandler;
import org.ballcat.fastexcel.head.I18nHeaderCellWriteHandler;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.ballcat.easyexcel;
package org.ballcat.fastexcel;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -23,13 +23,13 @@
import javax.validation.Validator;

import lombok.RequiredArgsConstructor;
import org.ballcat.easyexcel.aop.DynamicNameAspect;
import org.ballcat.easyexcel.aop.RequestExcelArgumentResolver;
import org.ballcat.easyexcel.aop.ResponseExcelReturnValueHandler;
import org.ballcat.easyexcel.config.ExcelConfigProperties;
import org.ballcat.easyexcel.head.EmptyHeadGenerator;
import org.ballcat.easyexcel.processor.NameProcessor;
import org.ballcat.easyexcel.processor.NameSpelExpressionProcessor;
import org.ballcat.fastexcel.aop.DynamicNameAspect;
import org.ballcat.fastexcel.aop.RequestExcelArgumentResolver;
import org.ballcat.fastexcel.aop.ResponseExcelReturnValueHandler;
import org.ballcat.fastexcel.config.ExcelConfigProperties;
import org.ballcat.fastexcel.head.EmptyHeadGenerator;
import org.ballcat.fastexcel.processor.NameProcessor;
import org.ballcat.fastexcel.processor.NameSpelExpressionProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

package org.ballcat.easyexcel.annotation;
package org.ballcat.fastexcel.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.alibaba.excel.read.builder.AbstractExcelReaderParameterBuilder;
import org.ballcat.easyexcel.handler.DefaultAnalysisEventListener;
import org.ballcat.easyexcel.handler.ListAnalysisEventListener;
import cn.idev.excel.read.builder.AbstractExcelReaderParameterBuilder;
import org.ballcat.fastexcel.handler.DefaultAnalysisEventListener;
import org.ballcat.fastexcel.handler.ListAnalysisEventListener;

/**
* 导入excel
Expand Down Expand Up @@ -69,4 +69,9 @@
*/
int headRowNumber() default 1;

/**
* The number of rows to read, the default is all, start with 0.
*/
int numRows() default -1;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
* limitations under the License.
*/

package org.ballcat.easyexcel.annotation;
package org.ballcat.fastexcel.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.handler.WriteHandler;
import org.ballcat.easyexcel.fill.FillDataSupplier;
import org.ballcat.easyexcel.head.HeadGenerator;
import cn.idev.excel.converters.Converter;
import cn.idev.excel.support.ExcelTypeEnum;
import cn.idev.excel.write.handler.WriteHandler;
import org.ballcat.fastexcel.fill.FillDataSupplier;
import org.ballcat.fastexcel.head.HeadGenerator;

/**
* `@ResponseExcel 注解`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package org.ballcat.easyexcel.annotation;
package org.ballcat.fastexcel.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.ballcat.easyexcel.head.HeadGenerator;
import org.ballcat.fastexcel.head.HeadGenerator;

/**
* 用于指定导入导出的 excel 的 sheet 属性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.ballcat.easyexcel.aop;
package org.ballcat.fastexcel.aop;

import java.time.LocalDateTime;
import java.util.Objects;
Expand All @@ -24,8 +24,8 @@
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.ballcat.easyexcel.annotation.ResponseExcel;
import org.ballcat.easyexcel.processor.NameProcessor;
import org.ballcat.fastexcel.annotation.ResponseExcel;
import org.ballcat.fastexcel.processor.NameProcessor;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
Expand Down
Loading
Loading