当前位置: 首页 > wzjs >正文

保定网站公司那家好百度推广seo优化

保定网站公司那家好,百度推广seo优化,电脑软件下载平台哪个好,制作营销网站使用word制作模版文件 使用Freemarker插值语法在需要替换的地方设置变量 把模版文件转换为xml文件保存 把模版文件复制到项目中并修改后缀.ftl pom引入freemarker <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot…
使用word制作模版文件

使用Freemarker插值语法在需要替换的地方设置变量
在这里插入图片描述

把模版文件转换为xml文件保存

在这里插入图片描述

把模版文件复制到项目中并修改后缀.ftl

在这里插入图片描述

pom引入freemarker
    <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId></dependency>
编写一个工具类 WordUtils
package com.gsafety.bg.emis.event.service.utils;import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URLEncoder;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.experimental.UtilityClass;/*** word生成工具类** @author :王建* @since :2023-05-12 15:01*/
@UtilityClass
public class WordUtils {/*** 生成 word 文档方法** @param dataMap      要填充的数据* @param templateName 模版名称* @param fileName     要输出的文件路径* @throws Exception 抛出的异常*/public static void generateWord(Map<String, Object> dataMap, String templateName, String fileName, HttpServletResponse response) throws Exception {// 设置FreeMarker的版本和编码格式Configuration configuration = new Configuration(Configuration.VERSION_2_3_31);configuration.setDefaultEncoding("UTF-8");configuration.setURLEscapingCharset("UTF-8");configuration.setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);// 此处把模版文件都放在 resources 下的 templates 中configuration.setClassForTemplateLoading(WordUtils.class, "/templates");// 设置FreeMarker生成Word文档所需要的模板Template tem = configuration.getTemplate(templateName, "UTF-8");ByteArrayOutputStream baos = new ByteArrayOutputStream();Writer out = new OutputStreamWriter(baos);tem.process(dataMap, out);byte[] bytes = baos.toByteArray();response.setCharacterEncoding("utf-8");response.setContentType("application/x-msdownload");fileName = URLEncoder.encode(fileName, "UTF-8");response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");response.setHeader("FileName", fileName);response.setContentLength(bytes.length);ServletOutputStream outputStream = response.getOutputStream();outputStream.write(bytes);outputStream.flush();outputStream.close();}
}
调用生成word文件
 AiExportReportTemplateReq templateParams = new AiExportReportTemplateReq().setCurrentTime(DateUtil.format(new Date(), "yyyy年MM月dd日")).setName("xxxxxx");WordUtils.generateWord(BeanUtil.beanToMap(templateParams),"你好.ftl", "你好-01.docx", response);
http://www.dtcms.com/wzjs/481117.html

相关文章:

  • 中山营销型网站建设百度搜索关键词排名靠前
  • 百度提交wordpress长沙seo服务哪个公司好
  • 建个网站能赚钱吗微营销平台有哪些
  • 浙江网站建设费用重庆百度seo
  • 龙华民治网站建设公司深圳百度推广
  • 网站php源码web成品网站源码免费
  • 南宁网站怎么做seo东莞整站优化排名
  • 天津建设厅 注册中心网站重庆seo点击工具
  • app优化网站太原最新情况
  • 一个网站如何做推广方案大连企业黄页电话
  • 工商注册在哪个网站百度百度一下官网
  • 有什么可以下载软件的网站360推广登陆入口
  • 广州网站建设公司电话搜索引擎大全网站
  • 网站品牌词优化怎么做网络优化公司
  • 海南建设培训与执业资格注册中心网站百度推广代运营公司
  • 我要做个网站怎么联系百度客服
  • 受欢迎的徐州网站建设网站seo优化有哪些方面
  • 站酷官网入口百度竞价
  • 网站建设思路方向代运营电商公司排行榜
  • 网站开发 ssh 菜鸟百度站内搜索
  • 有什么网站可以做设计兼职的百度客服24小时电话
  • 建设网站的法律声明企业网址
  • wordpress 制作手机站自己怎么做网站
  • photoshop网站设计全国免费发布信息平台
  • 苏州免费网页制作模板网站seo策划方案
  • 在网上怎么做网站微信营销系统
  • 广元企业网站建设百度竞价推广开户
  • 网站建设横向发展纵向发展深圳网络推广培训中心
  • 深圳门户网站建设营销软件培训
  • 网站建设需要什么系统实体店引流推广方法