From 6a1717908661ab631485fb5db45dd1e7c60944d2 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 15 Sep 2021 20:40:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A1=AB=E5=85=85=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=A8=AA=E5=90=91=E6=A0=B7=E5=BC=8F=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20[Issue=20#1651]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/AbstractVerticalCellStyleStrategy.java | 10 +++++----- .../write/style/HorizontalCellStyleStrategy.java | 11 ++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/style/AbstractVerticalCellStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/AbstractVerticalCellStyleStrategy.java index 8ba8bd2c..7d8e1b46 100644 --- a/src/main/java/com/alibaba/excel/write/style/AbstractVerticalCellStyleStrategy.java +++ b/src/main/java/com/alibaba/excel/write/style/AbstractVerticalCellStyleStrategy.java @@ -18,7 +18,7 @@ public abstract class AbstractVerticalCellStyleStrategy extends AbstractCellStyl @Override protected void setHeadCellStyle(CellWriteHandlerContext context) { - if (!continueProcessing(context)) { + if (stopProcessing(context)) { return; } WriteCellData cellData = context.getCellDataList().get(0); @@ -27,7 +27,7 @@ public abstract class AbstractVerticalCellStyleStrategy extends AbstractCellStyl @Override protected void setContentCellStyle(CellWriteHandlerContext context) { - if (!continueProcessing(context)) { + if (stopProcessing(context)) { return; } WriteCellData cellData = context.getCellDataList().get(0); @@ -64,11 +64,11 @@ public abstract class AbstractVerticalCellStyleStrategy extends AbstractCellStyl + "'contentCellStyle(Head head)' must be implemented."); } - protected boolean continueProcessing(CellWriteHandlerContext context) { + protected boolean stopProcessing(CellWriteHandlerContext context) { List> cellDataList = context.getCellDataList(); if (CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1) { - return false; + return true; } - return context.getHeadData() != null; + return context.getHeadData() == null; } } diff --git a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java index d33a2a74..58b0836a 100644 --- a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java +++ b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java @@ -34,7 +34,7 @@ public class HorizontalCellStyleStrategy extends AbstractCellStyleStrategy { @Override protected void setHeadCellStyle(CellWriteHandlerContext context) { - if (!continueProcessing(context) || headWriteCellStyle == null) { + if (stopProcessing(context) || headWriteCellStyle == null) { return; } WriteCellData cellData = context.getCellDataList().get(0); @@ -43,7 +43,7 @@ public class HorizontalCellStyleStrategy extends AbstractCellStyleStrategy { @Override protected void setContentCellStyle(CellWriteHandlerContext context) { - if (!continueProcessing(context) || CollectionUtils.isEmpty(contentWriteCellStyleList)) { + if (stopProcessing(context) || CollectionUtils.isEmpty(contentWriteCellStyleList)) { return; } WriteCellData cellData = context.getCellDataList().get(0); @@ -55,12 +55,9 @@ public class HorizontalCellStyleStrategy extends AbstractCellStyleStrategy { } } - protected boolean continueProcessing(CellWriteHandlerContext context) { + protected boolean stopProcessing(CellWriteHandlerContext context) { List> cellDataList = context.getCellDataList(); - if (CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1) { - return false; - } - return true; + return CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1; } }