Browse Source

修复最长匹配策略不同表格会有影响的bug #1010

2.1.x
Jiaju Zhuang 5 years ago
parent
commit
d44523d142
  1. 2
      pom.xml
  2. 6
      src/main/java/com/alibaba/excel/write/style/column/LongestMatchColumnWidthStyleStrategy.java
  3. 3
      update.md

2
pom.xml

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>2.2.0-beta1</version> <version>2.2.0-beta2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>easyexcel</name> <name>easyexcel</name>

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 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) {

3
update.md

@ -1,3 +1,6 @@
# 2.2.0-beta1
* 修复最长匹配策略不同表格会有影响的bug [Issue #1010](https://github.com/alibaba/easyexcel/issues/1010)
# 2.2.0-beta1 # 2.2.0-beta1
* 重写主流程,代码更加优雅 * 重写主流程,代码更加优雅
* 修复用String接收日期、数字和excel显示不一致的bug(不是完美修复,但是大部分情况已经兼容) * 修复用String接收日期、数字和excel显示不一致的bug(不是完美修复,但是大部分情况已经兼容)

Loading…
Cancel
Save