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

淄博网赢网站建设最新热搜新闻事件

淄博网赢网站建设,最新热搜新闻事件,网络营销方法有哪些,制作二维码生成器Java poi 模板导出Word 带图片 重点&#xff01;&#xff01;&#xff01; 官方文档&#xff1a;https://deepoove.com/poi-tl/#_maven 最终效果 模板 其实内容都在官方文档里写的非常明白了 我这里只是抛砖引玉。 Maven依赖 <poi.version>4.1.2</poi.version>…

Java poi 模板导出Word 带图片

重点!!!

官方文档:https://deepoove.com/poi-tl/#_maven

最终效果

在这里插入图片描述

模板

在这里插入图片描述

其实内容都在官方文档里写的非常明白了 我这里只是抛砖引玉。

Maven依赖

 	<poi.version>4.1.2</poi.version><poi.tl.version>1.10.0</poi.tl.version>
<!-- excel工具 --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>${poi.version}</version></dependency><!--poi Word--><dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>${poi.tl.version}</version></dependency>

代码

    @GetMapping("/word/export/{id}")public void word(@PathVariable("id") Long id,HttpServletResponse response){//这里自己查询需要导出的内容GenPersonWordInfoVO wordInfo = genPersonBaseService.getWordInfo(id);//将JavaBean转为map HashMap<String, Object> map = new HashMap<>();Field[] fields = wordInfo.getClass().getDeclaredFields();for (Field field : fields) {field.setAccessible(true);try {map.put(field.getName(), field.get(wordInfo));} catch (IllegalAccessException e) {e.printStackTrace();}}//这里放入图片map.put("headImg", Pictures.ofUrl(wordInfo.getHeadImg()).size(100, 150).center().create());//这里声明这些字段是列表 需要使用LoopRowTableRenderPolicy 类来处理 看名字也可以发现是循环table的行LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();Configure config = Configure.builder().bind("healthHistory", policy).bind("checkHistory", policy).bind("touchHistory", policy).bind("diagnosisHistory", policy).bind("treatmentHistory", policy).build();//加载模板文件 从resources目录下加载ClassPathResource resource = new ClassPathResource("template/person_file_template.docx");XWPFTemplate template = null;try {template = XWPFTemplate.compile(resource.getInputStream(),config).render(map);ServletOutputStream out = response.getOutputStream();response.setContentType("application/force-download");response.addHeader("Content-Disposition", "attachment;fileName=" + System.currentTimeMillis()+".docx");template.write(out);out.flush();out.close();template.close();} catch (IOException e) {e.printStackTrace();}}

最后,官方文档非常详细,完全可以参考官方文档。

http://www.yayakq.cn/news/178206/

相关文章:

  • 可视化的做网站的app扬州市住房建设局网站
  • 河南做网站团队哪里可以做外贸网站
  • 广东网站建设工作官网优化
  • 重庆装修网站建设城阳网站开发
  • 重庆南坪网站建设公司快速排名优化
  • 邯郸网站设计哪家专业wordpress首页循环
  • 网站开发目的简介南京网站a建设云世家
  • 长沙做最好网站做网站云主机
  • 织梦移动端网站怎么做济南网站制作专业
  • 网站刷流量对网站有影响吗哪个网站好
  • 汕头网站设计有限公司现在都用什么软件做网站
  • dede网站模板安装wordpress页眉文字链接
  • 网站建设流程咨询网站项目下载
  • 沈阳设计网站自己有网站怎么做app
  • 最好的dm单网站建设步步高网站建设报告
  • 嘉兴seo排名龙岩整站优化
  • 百度新闻搜索兰州seo实战优化
  • 广西建设培训网seo成创
  • 企业网站建设项目选择seo网站排名优化
  • 从化市营销型网站建设wordpress post攻击
  • 策划书网站项目目标需求分析便宜正品的购物app
  • 购物网站建设需要多少钱外贸平台哪个网站最好不收费
  • 做网站的画布是多少物流网络平台建设
  • 网站建设 互诺科技友情链接交换的作用在于
  • 郑州网站制作工作室asp网站ftp入侵
  • 做电商网站有什语言好成都市温江建设局网站
  • 网站建设中 页面源代码wordpress自定义文章目录
  • 企业门户网站建设方案后台管理私人订制网站的建设的设计表
  • 网站做收付款接口搜索引擎优化好做吗
  • 班级网站建设思路张家界seo网站优化