// 因为我要动态获取日期dateList是日期
EasyExcelUtils.writeExcel(response,
fileName, sheetName, head(dateList), fillData(dateList, bedsInfos));
private List<List<String>> head(List<LocalDate> dateList) {
List<List<String>> headTitles = Lists.newArrayList();
// 固定title
String billPeriodHead = "自定义日期区间";
headTitles.add(Lists.newArrayList(billPeriodHead, "序号", "序号"));
headTitles.add(Lists.newArrayList(billPeriodHead, "船号", "船号"));
headTitles.add(Lists.newArrayList(billPeriodHead, "持证人", "持证人"));
List<String> paymentTitles = Lists.newArrayList("上午", "下午");
for (LocalDate localDate : dateList) {
for (String paymentTitle : paymentTitles) {
headTitles.add(Lists.newArrayList(billPeriodHead, String.valueOf(localDate.getDayOfMonth()) + "日",
paymentTitle));
}
}
return headTitles;
}
效果