From a16b181c4ed56ce0672168194afd6b3bc0303caf Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 22:19:21 +0800 Subject: [PATCH 1/2] fix class cast error --- .../com/alibaba/excel/util/ClassUtils.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index d2ac7135..1447a078 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -1,20 +1,5 @@ package com.alibaba.excel.util; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; - import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; @@ -34,7 +19,6 @@ import com.alibaba.excel.metadata.property.FontProperty; import com.alibaba.excel.metadata.property.NumberFormatProperty; import com.alibaba.excel.metadata.property.StyleProperty; import com.alibaba.excel.write.metadata.holder.WriteHolder; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -43,6 +27,11 @@ import lombok.Setter; import org.apache.commons.collections4.CollectionUtils; import org.springframework.cglib.beans.BeanMap; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -564,11 +553,13 @@ public class ClassUtils { FieldCacheKey(Class clazz, ConfigurationHolder configurationHolder) { this.clazz = clazz; - WriteHolder writeHolder = (WriteHolder)configurationHolder; - this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); - this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); - this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); - this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + if (configurationHolder instanceof WriteHolder) { + WriteHolder writeHolder = (WriteHolder) configurationHolder; + this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); + this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); + this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); + this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + } } } From 90dd2f4e3d8de59f841062c51cf97508996d6f0e Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Fri, 19 May 2023 15:04:19 +0800 Subject: [PATCH 2/2] update write test import package --- .../java/com/alibaba/easyexcel/test/demo/write/WriteTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index d224c1d6..990f2630 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.Set; import com.alibaba.easyexcel.test.core.head.ComplexHeadData; -import com.alibaba.easyexcel.test.demo.read.ConverterData; import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter;