From 5d25eb7073b178fc9f6223b0d4dc0f78eb6831a6 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Fri, 9 Apr 2021 11:21:01 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"easyexcel=E6=95=B4=E4=BD=93=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E6=8F=90=E5=8D=873%"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easyexcel | 1 - .../test/core/style/AnnotationStyleData.java | 21 ----- .../test/core/style/LoopMergeData.java | 17 ---- .../core/style/OnceAbsoluteMergeData.java | 19 ----- .../SimpleVerticalCellStyleStrategy.java | 52 ------------ .../test/core/style/StyleDataTest.java | 80 ------------------- 6 files changed, 190 deletions(-) delete mode 160000 easyexcel delete mode 100644 src/test/java/com/alibaba/easyexcel/test/core/style/AnnotationStyleData.java delete mode 100644 src/test/java/com/alibaba/easyexcel/test/core/style/LoopMergeData.java delete mode 100644 src/test/java/com/alibaba/easyexcel/test/core/style/OnceAbsoluteMergeData.java delete mode 100644 src/test/java/com/alibaba/easyexcel/test/core/style/SimpleVerticalCellStyleStrategy.java diff --git a/easyexcel b/easyexcel deleted file mode 160000 index 4076b897..00000000 --- a/easyexcel +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4076b897953b18f9e96c278c6929325e89f2be12 diff --git a/src/test/java/com/alibaba/easyexcel/test/core/style/AnnotationStyleData.java b/src/test/java/com/alibaba/easyexcel/test/core/style/AnnotationStyleData.java deleted file mode 100644 index dd5dac60..00000000 --- a/src/test/java/com/alibaba/easyexcel/test/core/style/AnnotationStyleData.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.alibaba.easyexcel.test.core.style; - -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.write.style.ContentFontStyle; -import com.alibaba.excel.annotation.write.style.ContentStyle; -import lombok.Data; - -/** - * @author Pengliang Zhao - */ -@Data -public class AnnotationStyleData { - @ContentStyle(dataFormat = (short)1, rotation = (short)1, indent = (short)1, leftBorderColor = (short)1, - rightBorderColor = (short)1, topBorderColor = (short)1, bottomBorderColor = (short)1, - fillForegroundColor = (short)1, fillBackgroundColor = (short)1) - @ContentFontStyle(fontHeightInPoints = (short)1, color = (short)1, typeOffset = (short)1, charset = (short)1) - @ExcelProperty("字符串") - private String string; - @ExcelProperty("字符串1") - private String string1; -} diff --git a/src/test/java/com/alibaba/easyexcel/test/core/style/LoopMergeData.java b/src/test/java/com/alibaba/easyexcel/test/core/style/LoopMergeData.java deleted file mode 100644 index 77c5363f..00000000 --- a/src/test/java/com/alibaba/easyexcel/test/core/style/LoopMergeData.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.alibaba.easyexcel.test.core.style; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -/** - * @author Pengliang Zhao - */ -@Data -public class LoopMergeData { - @ExcelProperty(value = "洗漱种类", index = 0) - private String category; - @ExcelProperty(value = "毛巾名称", index = 1) - private String towel; - @ExcelProperty(value = "毛巾尺寸", index = 2) - private String size; -} diff --git a/src/test/java/com/alibaba/easyexcel/test/core/style/OnceAbsoluteMergeData.java b/src/test/java/com/alibaba/easyexcel/test/core/style/OnceAbsoluteMergeData.java deleted file mode 100644 index 09de338c..00000000 --- a/src/test/java/com/alibaba/easyexcel/test/core/style/OnceAbsoluteMergeData.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.alibaba.easyexcel.test.core.style; - -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.write.style.OnceAbsoluteMerge; -import lombok.Data; - -/** - * @author Pengliang Zhao - */ -@Data -@OnceAbsoluteMerge(firstRowIndex = (short)0, lastRowIndex = (short)2, firstColumnIndex = (short)0, lastColumnIndex = (short)2) -public class OnceAbsoluteMergeData { - @ExcelProperty(value = "洗漱种类", index = 0) - private String category; - @ExcelProperty(value = "毛巾名称", index = 1) - private String towel; - @ExcelProperty(value = "毛巾尺寸", index = 2) - private String size; -} diff --git a/src/test/java/com/alibaba/easyexcel/test/core/style/SimpleVerticalCellStyleStrategy.java b/src/test/java/com/alibaba/easyexcel/test/core/style/SimpleVerticalCellStyleStrategy.java deleted file mode 100644 index 9f4d3ac2..00000000 --- a/src/test/java/com/alibaba/easyexcel/test/core/style/SimpleVerticalCellStyleStrategy.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.alibaba.easyexcel.test.core.style; - -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.IndexedColors; - -import com.alibaba.excel.annotation.write.style.ContentFontStyle; -import com.alibaba.excel.annotation.write.style.ContentStyle; -import com.alibaba.excel.metadata.Head; -import com.alibaba.excel.metadata.property.FontProperty; -import com.alibaba.excel.metadata.property.StyleProperty; -import com.alibaba.excel.write.metadata.style.WriteCellStyle; -import com.alibaba.excel.write.metadata.style.WriteFont; -import com.alibaba.excel.write.style.AbstractVerticalCellStyleStrategy; - -/** - * @author Pengliang Zhao - */ -public class SimpleVerticalCellStyleStrategy extends AbstractVerticalCellStyleStrategy { - private StyleProperty styleProperty = StyleProperty.build(AnnotationStyleData.class.getAnnotation(ContentStyle.class)); - private FontProperty fontProperty = FontProperty.build(AnnotationStyleData.class.getAnnotation(ContentFontStyle.class)); - - @Override - protected WriteCellStyle headCellStyle(Head head) { - WriteCellStyle writeCellStyle = WriteCellStyle.build(styleProperty, fontProperty); - if (head.getColumnIndex() == 0) { - writeCellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); - WriteFont writeFont = new WriteFont(); - writeFont.setItalic(true); - writeFont.setStrikeout(true); - writeFont.setTypeOffset(Font.SS_NONE); - writeFont.setUnderline(Font.U_DOUBLE); - writeFont.setBold(true); - writeFont.setCharset((int)Font.DEFAULT_CHARSET); - } else { - writeCellStyle.setFillForegroundColor(IndexedColors.BLUE.getIndex()); - } - return writeCellStyle; - } - - @Override - protected WriteCellStyle contentCellStyle(Head head) { - WriteCellStyle writeCellStyle = new WriteCellStyle(); - writeCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); - if (head.getColumnIndex() == 0) { - writeCellStyle.setFillForegroundColor(IndexedColors.DARK_GREEN.getIndex()); - } else { - writeCellStyle.setFillForegroundColor(IndexedColors.PINK.getIndex()); - } - return writeCellStyle; - } -} diff --git a/src/test/java/com/alibaba/easyexcel/test/core/style/StyleDataTest.java b/src/test/java/com/alibaba/easyexcel/test/core/style/StyleDataTest.java index dc61c933..4e170944 100644 --- a/src/test/java/com/alibaba/easyexcel/test/core/style/StyleDataTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/core/style/StyleDataTest.java @@ -17,17 +17,13 @@ import org.junit.runners.MethodSorters; import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.annotation.write.style.OnceAbsoluteMerge; import com.alibaba.excel.metadata.Head; -import com.alibaba.excel.metadata.property.LoopMergeProperty; -import com.alibaba.excel.metadata.property.OnceAbsoluteMergeProperty; import com.alibaba.excel.write.merge.LoopMergeStrategy; import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy; import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteFont; import com.alibaba.excel.write.style.AbstractVerticalCellStyleStrategy; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; -import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy; @@ -40,19 +36,11 @@ public class StyleDataTest { private static File file07; private static File file03; - private static File file04; - private static File file05; - private static File file06; - private static File file08; @BeforeClass public static void init() { file07 = TestFileUtil.createNewFile("style07.xlsx"); file03 = TestFileUtil.createNewFile("style03.xls"); - file04 = TestFileUtil.createNewFile("simpleVerticalCellStyleStrategy01.xls"); - file05 = TestFileUtil.createNewFile("longestMatchColumnWidthStyleStrategy01.xls"); - file06 = TestFileUtil.createNewFile("loopMergeStrategy01.xls"); - file08 = TestFileUtil.createNewFile("onceAbsoluteMergeStrategy01.xls"); } @Test @@ -129,37 +117,6 @@ public class StyleDataTest { .doWrite(data10()); } - @Test - public void t05AbstractVerticalCellStyleStrategy03() { - AbstractVerticalCellStyleStrategy verticalCellStyleStrategy = new SimpleVerticalCellStyleStrategy(); - EasyExcel.write(file04, AnnotationStyleData.class).registerWriteHandler(verticalCellStyleStrategy).sheet() - .doWrite(data1()); - } - - @Test - public void t06longestMatchColumnWidthStyleStrategy() { - EasyExcel.write(file05, StyleData.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) - .sheet("模板").doWrite(data()); - } - - @Test - public void t07loopMergeStrategy() { - LoopMergeProperty loopMergeProperty = new LoopMergeProperty(1, 2); - loopMergeProperty.setEachRow(2); - loopMergeProperty.setColumnExtend(1); - EasyExcel.write(file06, LoopMergeData.class).registerWriteHandler(new LoopMergeStrategy(loopMergeProperty, 1)) - .sheet("模板").doWrite(data2()); - } - - @Test - public void to8onceAbsoluteMergeStrategy() { - OnceAbsoluteMerge onceAbsoluteMerge = OnceAbsoluteMergeData.class.getAnnotation(OnceAbsoluteMerge.class); - OnceAbsoluteMergeProperty onceAbsoluteMergeProperty = OnceAbsoluteMergeProperty.build(onceAbsoluteMerge); - OnceAbsoluteMergeStrategy onceAbsoluteMergeStrategy = new OnceAbsoluteMergeStrategy(onceAbsoluteMergeProperty); - EasyExcel.write(file08, OnceAbsoluteMergeData.class).registerWriteHandler(onceAbsoluteMergeStrategy).sheet("模板") - .doWrite(data3()); - } - private void readAndWrite(File file) { SimpleColumnWidthStyleStrategy simpleColumnWidthStyleStrategy = new SimpleColumnWidthStyleStrategy(50); SimpleRowHeightStyleStrategy simpleRowHeightStyleStrategy = @@ -199,43 +156,6 @@ public class StyleDataTest { return list; } - private List data1() { - List list = new ArrayList(); - AnnotationStyleData data = new AnnotationStyleData(); - data.setString("字符串0"); - data.setString1("字符串01"); - AnnotationStyleData data1 = new AnnotationStyleData(); - data1.setString("字符串1"); - data1.setString1("字符串11"); - list.add(data); - list.add(data1); - return list; - } - - private List data2() { - List list = new ArrayList(); - for (int i = 0; i <= 5; i++) { - LoopMergeData loopMergeData = new LoopMergeData(); - loopMergeData.setCategory("洗漱用品"); - loopMergeData.setTowel("毛巾"); - loopMergeData.setSize("10" + i + "#"); - list.add(loopMergeData); - } - return list; - } - - private List data3() { - List list = new ArrayList(); - for (int i = 0; i <= 5; i++) { - OnceAbsoluteMergeData onceAbsoluteMergeData = new OnceAbsoluteMergeData(); - onceAbsoluteMergeData.setCategory("洗漱用品"); - onceAbsoluteMergeData.setTowel("毛巾"); - onceAbsoluteMergeData.setSize("10" + i + "#"); - list.add(onceAbsoluteMergeData); - } - return list; - } - private List data10() { List list = new ArrayList(); for (int i = 0; i < 10; i++) {