版本
在本地创造下面两个类,包路径要一样
创建完成后这样:
在本地的BaseExportService中重写setCellWith方法
public void setCellWith(List<ExcelExportEntity> excelParams, Sheet sheet) {
for (int i = 0; i < excelParams.size(); i++) {
sheet.autoSizeColumn(i);
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 17 / 10); // 中文宽度
//设置最小宽度,防止title字符过短导致内容折叠显示,体验不佳
int minWidth = excelParams.get(i).getName().length() * 1600;
if (sheet.getColumnWidth(i) < minWidth)
sheet.setColumnWidth(i, minWidth); // 无数据额外处理
}
}
此处借鉴了:
原文链接:https://blog.youkuaiyun.com/weixin_43836520/article/details/120304557
在BaseExportService中:
完成修改:
109行的: int maxHeight = maxHeight + (listMaxHeight - 1);
改成 : maxHeight = maxHeight + (listMaxHeight - 1);
结果: