From 63c830f2121e706e501eb49be70351617beed87e Mon Sep 17 00:00:00 2001 From: duanqiaoyanyu <825388931@qq.com> Date: Mon, 9 Aug 2021 17:55:55 +0800 Subject: [PATCH 1/3] fix: Fix the continuous occurrence of {}{} filled templates in excel, causing rendering failure after the first one --- .../alibaba/excel/write/executor/ExcelWriteFillExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java index 5930a311..eac548cc 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java @@ -455,7 +455,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { analysisCell.setCellType(WriteTemplateAnalysisCellTypeEnum.COLLECTION); } analysisCell.getVariableList().add(variable); - if (lastPrepareDataIndex == prefixIndex) { + if (lastPrepareDataIndex == prefixIndex && 0 == prefixIndex) { analysisCell.getPrepareDataList().add(StringUtils.EMPTY); } else { String data = convertPrepareData(value.substring(lastPrepareDataIndex, prefixIndex)); From 6a21626085ea09013eb2c44ab06672989e2c2585 Mon Sep 17 00:00:00 2001 From: duanqiaoyanyu <825388931@qq.com> Date: Tue, 10 Aug 2021 10:34:21 +0800 Subject: [PATCH 2/3] fix: Fix the continuous occurrence of {}{} filled templates in excel, causing rendering failure after the first one --- .../excel/write/executor/ExcelWriteFillExecutor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java index eac548cc..b115be13 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java @@ -412,6 +412,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { int startIndex = 0; int length = value.length(); int lastPrepareDataIndex = 0; + int variableCount = 0; out: while (startIndex < length) { int prefixIndex = value.indexOf(FILL_PREFIX, startIndex); if (prefixIndex < 0) { @@ -442,7 +443,10 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { String variable = value.substring(prefixIndex + 1, suffixIndex); if (StringUtils.isEmpty(variable)) { continue; + } else { + ++variableCount; } + int collectPrefixIndex = variable.indexOf(COLLECTION_PREFIX); if (collectPrefixIndex > -1) { if (collectPrefixIndex != 0) { @@ -455,16 +459,20 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { analysisCell.setCellType(WriteTemplateAnalysisCellTypeEnum.COLLECTION); } analysisCell.getVariableList().add(variable); - if (lastPrepareDataIndex == prefixIndex && 0 == prefixIndex) { + if (lastPrepareDataIndex == prefixIndex) { analysisCell.getPrepareDataList().add(StringUtils.EMPTY); } else { String data = convertPrepareData(value.substring(lastPrepareDataIndex, prefixIndex)); preparedData.append(data); analysisCell.getPrepareDataList().add(data); - analysisCell.setOnlyOneVariable(Boolean.FALSE); } lastPrepareDataIndex = suffixIndex + 1; } + + if (variableCount >= 1) { + analysisCell.setOnlyOneVariable(Boolean.FALSE); + } + return dealAnalysisCell(analysisCell, value, rowIndex, lastPrepareDataIndex, length, firstRowCache, preparedData); } From 38371a62bb1e0ddec0395ba4b33f3f336e8af0cb Mon Sep 17 00:00:00 2001 From: duanqiaoyanyu <825388931@qq.com> Date: Tue, 10 Aug 2021 11:26:28 +0800 Subject: [PATCH 3/3] fix: Fix the continuous occurrence of {}{} filled templates in excel, causing rendering failure after the first one --- .../alibaba/excel/write/executor/ExcelWriteFillExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java index b115be13..526802a0 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java @@ -469,7 +469,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { lastPrepareDataIndex = suffixIndex + 1; } - if (variableCount >= 1) { + if (variableCount > 1) { analysisCell.setOnlyOneVariable(Boolean.FALSE); }