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

商丘网站建设哪家值得信任上海建筑设计院有限公司停工

商丘网站建设哪家值得信任,上海建筑设计院有限公司停工,文档下载页面模板,php美食网站开发背景freemarker导出word 第一步、将word转换为xml格式第二步、将转换后的xml文件修改后缀为ftl后复制到项目 resources 目录下(可以自己新建一个文件夹放在文件夹中)第三步、格式化xml代码(如果问价太大可能会无法格式化)这时候需要在…

freemarker导出word

      • 第一步、将word转换为xml格式
      • 第二步、将转换后的xml文件修改后缀为ftl后复制到项目 resources 目录下(可以自己新建一个文件夹放在文件夹中)
      • 第三步、格式化xml代码(如果问价太大可能会无法格式化)这时候需要在idea中进行设置
      • 第四步、ftl文件值的替换
      • 第五步、工具类
      • POM

第一步、将word转换为xml格式

第二步、将转换后的xml文件修改后缀为ftl后复制到项目 resources 目录下(可以自己新建一个文件夹放在文件夹中)

第三步、格式化xml代码(如果问价太大可能会无法格式化)这时候需要在idea中进行设置

在这里插入图片描述
idea.max.intellisense.filesize=10000
idea.max.content.load.filesize=10000

第四步、ftl文件值的替换

${monthLowerALL!} 表示替换单个值遍历数组
<#list userList as user>编号:${user.id} 姓名:${user.username} ${user.age}<br/>
</#list>

第五步、工具类

@Slf4j
public class FreemarkerUtil {/*** 使用 Freemarker 生成 Word 文件** @param templateName 模板文件路径名称* @param fileName     生成的文件路径以及名称* @param dataModel    填充的数据对象*/public static void exportWord(String templateName, String fileName, Map<String, Object> dataModel) {generateFile(templateName, fileName, dataModel);}/*** 使用 Freemarker 生成指定文件返回流** @param templateName 模板文件路径名称* @param fileName     生成的文件名称* @param dataModel    填充的数据对象*/private static void generateFile(String templateName, String fileName, Map<String, Object> dataModel) {try {// 1、创建配置对象Configuration config = new Configuration(Configuration.VERSION_2_3_30);config.setDefaultEncoding("utf-8");//这里 templates 为你项目中resources目录下templates文件夹,相当于会拼接在你的 templateName参数前面config.setClassForTemplateLoading(FreemarkerUtil.class, "/templates");// 2、获取模板文件Template template = config.getTemplate(templateName, "utf-8");HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();response.setContentType("application/msword;charset=utf-8");response.setCharacterEncoding("utf-8");try {response.setHeader("Content-disposition", "attachment;filename=" + new String(fileName.getBytes("gb2312"), "ISO8859-1") + ".docx");} catch (UnsupportedEncodingException e) {e.printStackTrace();}template.process(dataModel, response.getWriter());} catch (Exception e) {e.printStackTrace();}}
}

###第六步、调用

 Map<String, Object> dataMap = Maps.newConcurrentMap();dataMap.put("totalIncomeAll", "123456789++");dataMap.put("monthLowerALL", "1960");// 执行导出FreemarkerUtil.exportWord("templates路径下对应的模板名称.ftl", "导出的模板名称", dataMap);

POM

<!-- 文档模板操作依赖 --><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.xdocreport.core</artifactId><version>2.0.2</version></dependency><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.xdocreport.document</artifactId><version>2.0.2</version></dependency><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.xdocreport.template</artifactId><version>2.0.2</version></dependency><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.xdocreport.document.docx</artifactId><version>2.0.2</version></dependency><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId><version>2.0.2</version></dependency>
http://www.yayakq.cn/news/66008/

相关文章:

  • 一级a做爰片免费网站视频WordPress wp-cache
  • 哈尔滨网站制作哪儿好薇seo属于运营还是技术
  • 手机端网站开发流程中国服装网官网
  • 青岛专业建设网站网站上点击图片局部放大如何做
  • 一个门户网站多少钱公司营业执照可以做几个网站
  • 课程网站建设发展趋势wordpress加速之gzip
  • 幼教资源网网站开发策划书无锡企业免费建站
  • 开源网站搭建自己做的网站如何联网
  • 雄安优秀网站建设哪家好北京建设网站公司推荐
  • 5h制作网站门户网站的定义
  • 东莞网站建设网如何部署asp网站
  • 网站运行速度慢的原因如何做网站主题
  • jsp网站架构引擎优化是什么工作
  • 一般在什么网站上做电子请帖网站建设布局样式
  • 网站每年多少钱管理咨询公司信息
  • 怎么去创建一个网站哪里有做网站系统
  • 天津智能网站建设费用wordpress整套主题
  • 简单的网站管理系统湛江房产信息网
  • 苏州园区建设网站首页小程序开发外包服务公司
  • 做一个网站成本多少百度号码查询平台
  • 网站关键词怎样优化全球展览设计的图片
  • 教育网站制作企业开发次元世界
  • 网站优化排名方法有哪些购物网站页面
  • 网站开发filter哔哩哔哩网页版怎么缓存视频
  • 什么叫营销型网站建设php网站怎么用mysql新建数据库
  • 网站秒收录工具网站内容编写方法
  • 深圳专业医疗网站建设商业广告公司排名
  • 广西建设厅招投标中心网站移动互联网技术网站
  • 保健食品东莞网站建设个人可以做电影网站吗
  • asp网站咋做网站建设扬州