Browse Source

去掉LongestMatchColumnWidthStyleStrategy缓存的static修饰符

2.1.x
zl 5 years ago
parent
commit
af2c388262
  1. 6
      src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java

6
src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java

@ -24,7 +24,7 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty
private static final int MAX_COLUMN_WIDTH = 255; private static final int MAX_COLUMN_WIDTH = 255;
private static final Map<Integer, Map<Integer, Integer>> CACHE = new HashMap<Integer, Map<Integer, Integer>>(8); private final Map<Integer, Map<Integer, Integer>> cache = new HashMap<Integer, Map<Integer, Integer>>(8);
@Override @Override
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head, protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head,
@ -33,10 +33,10 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty
if (!needSetWidth) { if (!needSetWidth) {
return; return;
} }
Map<Integer, Integer> maxColumnWidthMap = CACHE.get(writeSheetHolder.getSheetNo()); Map<Integer, Integer> maxColumnWidthMap = cache.get(writeSheetHolder.getSheetNo());
if (maxColumnWidthMap == null) { if (maxColumnWidthMap == null) {
maxColumnWidthMap = new HashMap<Integer, Integer>(16); maxColumnWidthMap = new HashMap<Integer, Integer>(16);
CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); cache.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
} }
Integer columnWidth = dataLength(cellDataList, cell, isHead); Integer columnWidth = dataLength(cellDataList, cell, isHead);
if (columnWidth < 0) { if (columnWidth < 0) {

Loading…
Cancel
Save