说明
在使用easypoi的时候,遇到了@ExcelCollection多层嵌套下第二层开始width不生效的问题。
一、 问题(设置width不生效)
二、 如何解决
找到源码的BaseExportService类的setCellWith方法
修改为递归的方式
public void setCellWith(List<ExcelExportEntity> excelParams, Sheet sheet,int index) {
for (int i = 0; i < excelParams.size(); i++) {
if (excelParams.get(i).getList() != null) {
this.setCellWith(excelParams.get(i).getList(),sheet,index);
} else {
sheet.setColumnWidth(index, (int) (256 * excelParams.get(i).getWidth()));
index++;
}
}
}
修改后