栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springcloud+esqypoi实现以模版批量导出word

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springcloud+esqypoi实现以模版批量导出word

一 、前端全选之后,导出所勾选的数据的word

easypoi 4.1.2

二、 项目结构

 

三、word模板

四、代码实现

1、controller层

 

@ApiOperation(value = "批量导出word", notes = "批量导出word")
@PostMapping("/exportDocs")
public void exportDocs(HttpServletResponse response,@RequestBody Long[] ids) {
    actorService.exportDocs(response,ids);
}

2、service层

 

 

void exportDocs(HttpServletResponse response,Long[] ids);

3.serviceimpl层

 

@Override
@Transactional
public void exportDocs(HttpServletResponse response,Long[] ids) {
    List list= baseMapper.batchEduActor(Arrays.asList(ids));
    Map map = new HashMap();
    for(int i =0;i 

4.mapper层

List batchEduActor(List ids);

5.xml


    select *  from edu_actor
    
        id in (
        
            #{id}
        
        )
    

 6.entity

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="EduActor对象", description="演员")
public class EduActor implements Serializable {

    private static final long serialVersionUID = 1L;

    @Excel(name = "演员ID")
    @ApiModelProperty(value = "演员ID")
    @JsonSerialize(using= ToStringSerializer.class)
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    @Excel(name = "演员姓名")
    @ApiModelProperty(value = "演员姓名")
    private String name;

    @Excel(name = "演员简介")
    @ApiModelProperty(value = "演员简介")
    private String intro;

    @Excel(name = "演员资历")
    @ApiModelProperty(value = "演员资历,一句话说明演员")
    private String career;

    @Excel(name = "头衔")
    @ApiModelProperty(value = "头衔 1高级演员 2首席演员")
    private Integer level;

    @Excel(name = "演员头像")
    @ApiModelProperty(value = "演员头像")
    private String avatar;

    @Excel(name = "排序")
    @ApiModelProperty(value = "排序")
    private Integer sort;

    @Excel(name = "逻辑删除")
    @ApiModelProperty(value = "逻辑删除 1(true)已删除, 0(false)未删除")
    @TableLogic
//    @TableField(fill = FieldFill.INSERT)
    private Integer isDeleted;

    @Excel(name = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime gmtCreate;

    @Excel(name = "更新时间")
  //  @TableField(fill = FieldFill.INSERT_UPDATE)
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    @ApiModelProperty(value = "更新时间")
    private LocalDateTime gmtModified;


}

 五、测试

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/708771.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号