Browse Source

修复填充调用横向样式策略报错 [Issue #1651]

developing
Jiaju Zhuang 3 years ago
parent
commit
6a17179086
  1. 10
      src/main/java/com/alibaba/excel/write/style/AbstractVerticalCellStyleStrategy.java
  2. 11
      src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java

10
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<WriteCellData<?>> cellDataList = context.getCellDataList();
if (CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1) {
return false;
return true;
}
return context.getHeadData() != null;
return context.getHeadData() == null;
}
}

11
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<WriteCellData<?>> cellDataList = context.getCellDataList();
if (CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1) {
return false;
}
return true;
return CollectionUtils.isEmpty(cellDataList) || cellDataList.size() > 1;
}
}

Loading…
Cancel
Save