6
触发场景描述
【必现】日期类型的字段自动列宽不生效,源码未对日期类型做处理。
触发Bug的代码 public class EasyIssueReport {
public static void main(String[] args) {
EasyExcel.write(getTestFileOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.head(Pojo.class)
.sheet().doWrite(getTestData());
}
static List<Pojo> getTestData() {
List<Pojo> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Pojo data = new Pojo();
data.setDate(new Date());
data.setLocalDate(LocalDate.now());
data.setLocalDateTime(LocalDateTime.now());
list.add(data);
}
return list;
}
@Data
public static class Pojo {
@ExcelProperty("date")
Date date;
@ExcelProperty("localDate")
LocalDate localDate;
@ExcelProperty("localDateTime")
LocalDateTime localDateTime;
@ExcelProperty("longText")
String text = "long long long long long long long text";
}
}
提示的异常或者没有达到的效果