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
@Override protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); if (!needSetWidth) { return; } 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; CellStyle cellStyle = cell.getCellStyle(); if (cellStyle != null) { cellStyle.setWrapText(true); } } Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); if (maxColumnWidth == null || columnWidth > maxColumnWidth) { maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); } }
1、这段代码是重写了LongestMatchColumnWidthStyleStrategy方法 2、为了自定义最大宽度,且当达到最大宽度时,单元格设置自动换行 3、debug调试过,确定到了具体的cell是执行了cellStyle.setWrapText(true); 4、实际下载的excel中变成表头有自动换行,目标单元格没有
The text was updated successfully, but these errors were encountered:
No branches or pull requests
异常代码
问题描述
1、这段代码是重写了LongestMatchColumnWidthStyleStrategy方法
2、为了自定义最大宽度,且当达到最大宽度时,单元格设置自动换行
3、debug调试过,确定到了具体的cell是执行了cellStyle.setWrapText(true);
4、实际下载的excel中变成表头有自动换行,目标单元格没有
The text was updated successfully, but these errors were encountered: