EXCEL导出
作者:互联网
pom依赖:
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.1.0</version>
</dependency>
public void export(HttpServletResponse response, @RequestBody DailyExpenseDetailsReq dailyExpenseDetailsReq)
throws Exception {
List<DailyExpenseDetailsEntity> list = dailyExpenseDetailsService.export(dailyExpenseDetailsReq);
List<DailyExpenseDetailsExportDTO> res = new ArrayList<>();
for(DailyExpenseDetailsEntity daily : list) {
DailyExpenseDetailsExportDTO expotrtDto = new DailyExpenseDetailsExportDTO();
// [0-送箱需求创建时间,1-送箱运单出库时间,2-送箱运单签收时间]
if("0".equals(daily.getTenancyBegin())) {
daily.setTenancyBegin("送箱需求创建时间");
}else if("1".equals(daily.getTenancyBegin())) {
daily.setTenancyBegin("送箱运单出库时间");
}else if("2".equals(daily.getTenancyBegin())) {
daily.setTenancyBegin("送箱运单签收时间");
}
// [0-收箱需求创建时间,1-收箱运单出库时间,2-收箱运单签收时间]
if("0".equals(daily.getTenancyEnd())) {
daily.setTenancyEnd("收箱需求创建时间");
}else if("1".equals(daily.getTenancyBegin())) {
daily.setTenancyEnd("收箱运单出库时间");
}else if("2".equals(daily.getTenancyBegin())) {
daily.setTenancyEnd("收箱运单签收时间");
}
if(daily.getAssociatedWithBill()) {
daily.setWithBill("有账单");
}else {
daily.setWithBill("无账单");
}
if(daily.getOverdue()) {
daily.setOverdueStr("已超期");
}else {
daily.setOverdueStr("未超期");
}
BeanUtils.copyProperties(daily, expotrtDto);
res.add(expotrtDto);
}
response.setHeader("content-Type", "application/vnd.ms-excel");
String fileName = URLEncoder.encode("日费用明细列表", "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), DailyExpenseDetailsExportDTO.class, res);
workbook.write(response.getOutputStream());
导出类型字段处理:
@Excel(name = "租期结束时间", width = 25,orderNum = "19",exportFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "租期开结束时间")
private Date leaseEndTime;
标签:运单,EXCEL,导出,equals,daily,else,送箱,收箱 来源: https://blog.csdn.net/weixin_38285470/article/details/121029540