From 51bf294b52aaf2fa456ca29ccc82761888e4f998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9C=AC=E9=BE=99?= <852026881@qq.com> Date: Mon, 26 Oct 2020 14:19:06 +0800 Subject: [PATCH] =?UTF-8?q?LongestMatchColumnWidthStyleStrategy=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=88=97=E5=AE=BDBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LongestMatchColumnWidthStyleStrategy设置列宽BUG:与spring集成时 ,由于bean是单例,CACHE内容不会改变,同一个报表只有第一次调用会动态设置列宽 --- .../style/column/LongestMatchColumnWidthStyleStrategy.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java index cc8dcb20..a00d63d7 100644 --- a/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java +++ b/src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java @@ -33,6 +33,12 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty if (!needSetWidth) { return; } + + //LongestMatchColumnWidthStyleStrategy设置列宽BUG:与spring集成时 ,由于bean是单例,CACHE内容不会改变,同一个报表只有第一次调用会动态设置列宽 + if (cell.getRowIndex() == 0 && cell.getColumnIndex() == 0) { + CACHE.clear(); + } + Map maxColumnWidthMap = cache.get(writeSheetHolder.getSheetNo()); if (maxColumnWidthMap == null) { maxColumnWidthMap = new HashMap(16);