jeecgboot excel自定义导出

@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;
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值