@AutoLog(value = "导出")
@ApiOperation(value = "导出", notes = "导出")
@PostMapping(value = "/dynamicExport")
public void dynamicExport(HttpServletResponse response,@RequestBody List<String> ids){
log.info("导出检查表单,ids={}", ids);
// TemplateExportParams exportParams = new TemplateExportParams("template/formSchedule.xlsx");
QueryWrapper<IqsFormSchedule> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",ids);
List<IqsFormSchedule> list = iIqsFormScheduleService.list(queryWrapper);
Map<String, Object> map = new HashMap<String, Object>(1);
map.put("details",list);
ExportParams entity=new ExportParams("测试","测试");
entity.setAddIndex(true);
String[] exportFields={"projectId","reporter","scheduleName","scheduleOwner"};
Workbook workbook = ExcelExportUtil.exportExcel(entity,IqsFormSchedule.class,list,exportFields);
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + UUID.randomUUID().toString().replace("-", "") + ".xls");
response.setCharacterEncoding("UTF-8");
BufferedOutputStream outputStream = null;
try {
outputStream = new BufferedOutputStream(response.getOutputStream());
workbook.write(outputStream);
outputStream.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="IqsFormSchedule对象", description="日程表单")
//@ExcelTarget("")
public class IqsFormSchedule implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "项目")
@Excel(name="项目")
private String projectId;
@ExcelExport(value = "记录人", sort = 5)
@ApiModelProperty(value = "记录人")
@Excel(name="记录人")
private String reporter;
@ExcelExport(value = "日程名称", sort = 1)
@ApiModelProperty(value = "日程名称")
@Excel(name="日程名称")
private String scheduleName;
@ExcelExport(value = "主持人", sort = 3)
@ApiModelProperty(value = "主持人")
@Excel(name="主持人")
private String scheduleOwner;
}