We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
触发场景描述 表格的sheet有三个,第一次发送邮件,列宽是根据数据自动列宽;第二次发送邮件,列宽未设置 触发Bug的代码
// 此处生命的CACHE是静态的,类被初始化后,所有类都共享 private static final 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, Integer relativeRowIndex, Boolean isHead) { boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); if (!needSetWidth) { return; } // 此处是从CACHE中获取,第一次发邮件时,CACHE中有3个key(0,1,2),第二次发邮件,sheetNo还是0,1,2,所以取出了上次发邮件的sheetNo对应的内容 Map<Integer, Integer> maxColumnWidthMap = CACHE.get(writeSheetHolder.getSheetNo()); if (maxColumnWidthMap == null) { maxColumnWidthMap = new HashMap<Integer, Integer>(16); CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); } Integer columnWidth = dataLength(cellDataList, cell, isHead); if (columnWidth < 0) { return; } if (columnWidth > MAX_COLUMN_WIDTH) { columnWidth = MAX_COLUMN_WIDTH; } // maxColumnWidthMap变量根据上面代码逻辑,就是上次发邮件sheet的map,此时columnIndex也是一样的,第二次发邮件时,maxColumnWidth不会为null,且与columnWidth基本相等,就不会进入设置宽度的方法,所以第二次发邮件时,宽度就未设置 Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); if (maxColumnWidth == null || columnWidth > maxColumnWidth) { maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); } }
提示的异常或者没有达到的效果 期望第二次发邮件时,也应该自动设置列宽,而不是从静态的CACHE获取,因为sheetNo,两次邮件会一样的,只是根据源码逻辑推断,如果是我使用错了,还望告知方案,感谢
The text was updated successfully, but these errors were encountered:
这个就是个bug,cache不能定义static
cache
static
Sorry, something went wrong.
修复最长匹配策略不同表格会有影响的bug #1010
d44523d
zhuangjiaju
No branches or pull requests
触发场景描述
表格的sheet有三个,第一次发送邮件,列宽是根据数据自动列宽;第二次发送邮件,列宽未设置
触发Bug的代码
提示的异常或者没有达到的效果
期望第二次发邮件时,也应该自动设置列宽,而不是从静态的CACHE获取,因为sheetNo,两次邮件会一样的,只是根据源码逻辑推断,如果是我使用错了,还望告知方案,感谢
The text was updated successfully, but these errors were encountered: