From 5b37ec243f69b8ef34810a6c0e99e06958d30938 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Sat, 18 Sep 2021 16:05:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E5=85=A5=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/alibaba/excel/constant/OrderConstant.java | 14 ++++++++++++-- .../write/metadata/holder/AbstractWriteHolder.java | 6 ++++++ .../alibaba/excel/write/style/DefaultStyle.java | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/alibaba/excel/constant/OrderConstant.java b/src/main/java/com/alibaba/excel/constant/OrderConstant.java index 54d438e5..309b6297 100644 --- a/src/main/java/com/alibaba/excel/constant/OrderConstant.java +++ b/src/main/java/com/alibaba/excel/constant/OrderConstant.java @@ -7,6 +7,16 @@ package com.alibaba.excel.constant; */ public class OrderConstant { + /** + * The system's own style + */ + public static int DEFAULT_DEFINE_STYLE = -70000; + + /** + * Annotation style definition + */ + public static int ANNOTATION_DEFINE_STYLE = -60000; + /** * Define style. */ @@ -15,10 +25,10 @@ public class OrderConstant { /** * default order. */ - public static final int DEFAULT_ORDER = 0; + public static int DEFAULT_ORDER = 0; /** * Sorting of styles written to cells. */ - public static final int FILL_STYLE = 50000; + public static int FILL_STYLE = 50000; } diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java index 2867bdc5..d6921681 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import com.alibaba.excel.constant.OrderConstant; import com.alibaba.excel.converters.Converter; import com.alibaba.excel.converters.ConverterKeyBuild; import com.alibaba.excel.converters.DefaultConverterLoader; @@ -235,6 +236,11 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ private void dealStyle(List handlerList) { WriteHandler styleStrategy = new AbstractVerticalCellStyleStrategy() { + @Override + public int order() { + return OrderConstant.ANNOTATION_DEFINE_STYLE; + } + @Override protected WriteCellStyle headCellStyle(Head head) { return WriteCellStyle.build(head.getHeadStyleProperty(), head.getHeadFontProperty()); diff --git a/src/main/java/com/alibaba/excel/write/style/DefaultStyle.java b/src/main/java/com/alibaba/excel/write/style/DefaultStyle.java index 38a43d58..139998ef 100644 --- a/src/main/java/com/alibaba/excel/write/style/DefaultStyle.java +++ b/src/main/java/com/alibaba/excel/write/style/DefaultStyle.java @@ -19,7 +19,7 @@ public class DefaultStyle extends HorizontalCellStyleStrategy { @Override public int order() { - return OrderConstant.DEFINE_STYLE - 1; + return OrderConstant.DEFAULT_DEFINE_STYLE; } public DefaultStyle() {