From 68200389fb5b72dc38e3f1233e8e18097d6e629e Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Thu, 21 Oct 2021 00:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=B7=E5=BC=8F=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E8=B6=85=E8=BF=87=E6=9C=80=E5=A4=A7=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metadata/holder/WriteWorkbookHolder.java | 21 ++++++++++--------- update.md | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java index 494473dc..73a680d6 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java @@ -10,6 +10,7 @@ import java.io.OutputStream; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import com.alibaba.excel.enums.HolderEnum; import com.alibaba.excel.exception.ExcelGenerateException; @@ -133,15 +134,15 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { /** * Used to cell style. */ - private Map> cellStyleIndexMap; + private Map> cellStyleIndexMap; /** * Used to font. */ - private Map fontMap; + private Map fontMap; /** * Used to data format. */ - private Map dataFormatMap; + private Map dataFormatMap; public WriteWorkbookHolder(WriteWorkbook writeWorkbook) { super(writeWorkbook, null); @@ -267,9 +268,9 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { useCache = false; } - Map cellStyleMap = cellStyleIndexMap.computeIfAbsent(styleIndex, + Map cellStyleMap = cellStyleIndexMap.computeIfAbsent(styleIndex, key -> MapUtils.newHashMap()); - CellStyle cellStyle = cellStyleMap.get(writeCellStyle); + CellStyle cellStyle = cellStyleMap.get(Objects.toString(writeCellStyle)); if (cellStyle != null) { return cellStyle; } @@ -285,7 +286,7 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { if (font != null) { cellStyle.setFont(font); } - cellStyleMap.put(writeCellStyle, cellStyle); + cellStyleMap.put(Objects.toString(writeCellStyle), cellStyle); return cellStyle; } @@ -301,12 +302,12 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { if (!useCache) { return StyleUtil.buildFont(workbook, originFont, writeFont); } - Font font = fontMap.get(writeFont); + Font font = fontMap.get(Objects.toString(writeFont)); if (font != null) { return font; } font = StyleUtil.buildFont(workbook, originFont, writeFont); - fontMap.put(writeFont, font); + fontMap.put(Objects.toString(writeFont), font); return font; } @@ -324,12 +325,12 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { if (!useCache) { return StyleUtil.buildDataFormat(workbook, dataFormatData); } - Short dataFormat = dataFormatMap.get(dataFormatData); + Short dataFormat = dataFormatMap.get(Objects.toString(dataFormatData)); if (dataFormat != null) { return dataFormat; } dataFormat = StyleUtil.buildDataFormat(workbook, dataFormatData); - dataFormatMap.put(dataFormatData, dataFormat); + dataFormatMap.put(Objects.toString(dataFormatData), dataFormat); return dataFormat; } diff --git a/update.md b/update.md index 70e11c8c..bb9763b1 100644 --- a/update.md +++ b/update.md @@ -3,6 +3,7 @@ * 修复填充样式可能丢失的问题 [Issue #2124](https://github.com/alibaba/easyexcel/issues/2124) * 修复填充数据为空 可能NPE的bug * 修复填充样式可能不生效bug +* 修复样式可能超过最大限制的bug # 3.0.0-beta3