版本
在本地创造下面两个类,包路径要一样


创建完成后这样:

在本地的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);
结果:

本文介绍了一种优化Excel导出服务的方法,通过调整表格列宽和自动调整大小功能,改善了中文内容的显示效果,并确保标题不会因字符过短而折叠,提升了用户体验。
3951

被折叠的 条评论
为什么被折叠?



