读取word模板导出文档(学习未验证)

读取word模板导出文档(学习未验证)

需要导入这个包

<!-- freemarker -->
<dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    <version>2.3.28</version>
</dependency>

解读:

(前提,其中读取的是ftl后缀的模板,这个好像是word设置域就是${username}那些,然后转换为xml在转换为ftl,可百度)

1.查询需要打印的数据

2.组装到一个map集合里面

3.读取模板

4.调用工具类TemplateUtils.createDoc方法生成word文档(TemplateUtils工具类附下面了)

5.读文件(也是调用接口 附下面了)

6.设置respnse信息 开始写

7.删除临时文件(也是调用接口 附下面了)

@IgnoreSysLog
@ApiOperation(value = "节水三同时上报-打印验收表", notes = "节水三同时上报-打印验收表", produces = "application/json")
@ApiImplicitParams({
   @ApiImplicitParam(paramType = "path", name = "waterBaseId", value = "节水三同时上报-删除", required = true, dataType = "long")})
@PostMapping(value = URI_SAVING_THREE_PRINT_CHECK)
public void printThreeSimultaneousCheck(@PathVariable("waterBaseId") Long waterBaseId, HttpServletResponse response) {
   
    if (LOGGER.isDebugEnabled()) {
   
        LOGGER.debug("节水三同时上报-打印验收表失败");
    }
    WaterSavingBaseTotalDTO waterSavingBaseTotalDTO = waterSavingService.checkSeeThreeSimultaneousReport(waterBaseId);
    WaterSavingBaseCheckDTO waterSavingBaseCheckDTO = waterSavingService.seeThreeSimultaneousReport(waterBaseId);


    final Map<String, Object> map = newHashMapWithExpectedSize(1);
    String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString();
    try {
   
        map.put("year", time.substring(0, 4));
        map.put("month", time.substring(5, 7));
        map.put("day", time.substring(8, 10));
        map.put("applicant", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getApplicant());
        map.put("constrotionProject", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getConstrotionProject());
        map.put("contactPerson", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getContactPerson());
        map.put("contactPhone", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getContactPhone());
        map.put("designUnit", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getDesignUnit());
        map.put("constructionUnit", waterSavingBaseCheckDTO.getConstructionUnit());
        map.put("controlUnit", waterSavingBaseCheckDTO.getControlUnit());
        map.put("constrotionAddress", waterSavingBaseTotalDTO.getWaterSavingBaseTotal().getConstrotionAddress());

        map.put("plannedArea", waterSavingBaseCheckDTO.getPlannedArea().
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值