Skip to content

Commit

Permalink
修复最长匹配策略不同表格会有影响的bug #1010
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangjiaju committed Mar 17, 2020
1 parent 3ef7c19 commit d44523d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.0-beta1</version>
<version>2.2.0-beta2</version>
<packaging>jar</packaging>
<name>easyexcel</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LongestMatchColumnWidthStyleStrategy extends AbstractColumnWidthSty

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
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head,
Expand All @@ -33,10 +33,10 @@ protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData>
if (!needSetWidth) {
return;
}
Map<Integer, Integer> maxColumnWidthMap = CACHE.get(writeSheetHolder.getSheetNo());
Map<Integer, Integer> maxColumnWidthMap = cache.get(writeSheetHolder.getSheetNo());
if (maxColumnWidthMap == null) {
maxColumnWidthMap = new HashMap<Integer, Integer>(16);
CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
cache.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
}
Integer columnWidth = dataLength(cellDataList, cell, isHead);
if (columnWidth < 0) {
Expand Down
3 changes: 3 additions & 0 deletions update.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.2.0-beta1
* 修复最长匹配策略不同表格会有影响的bug [Issue #1010](https://github.com/alibaba/easyexcel/issues/1010)

# 2.2.0-beta1
* 重写主流程,代码更加优雅
* 修复用String接收日期、数字和excel显示不一致的bug(不是完美修复,但是大部分情况已经兼容)
Expand Down

0 comments on commit d44523d

Please sign in to comment.