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

王烨个人简历百度seo找哪里

王烨个人简历,百度seo找哪里,招聘网站代理,成都网站建设好作者wangsz&#xff0c;想写一些关于word的工具&#xff0c;所以就写了这篇文章 1.首先&#xff0c;先导入所需要的依赖&#xff08;poi相关依赖即可&#xff09; <!-- POI --><dependency><groupId>org.apache.poi</groupId><artifactId>poi&l…

作者wangsz,想写一些关于word的工具,所以就写了这篇文章

1.首先,先导入所需要的依赖(poi相关依赖即可)

<!-- POI --><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>4.1.2</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>4.1.2</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>4.1.2</version></dependency><!-- poi-tl --><dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.9.1</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox --><dependency><groupId>org.apache.pdfbox</groupId><artifactId>pdfbox</artifactId><version>2.0.24</version></dependency><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13</version></dependency><dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>

2.依赖导入完成后,先了解一些poi基础知识,制作word模板

{{template}}
普通文本,渲染数据为:String或者TextRenderData

{{@template}}
图片,渲染数据为:PictureRenderData

{{#template}}
表格,渲染数据为:TableRenderData
{{*template}}
列表,渲染数据为:NumbericRenderData

3.编写生成word文档代码

 //将图片转换成字节数组public static byte[] getUrlByteArray(String imageUrl) throws IOException {URL url = new URL(imageUrl);try (InputStream inputStream = url.openStream();ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {byte[] buffer = new byte[4096];int bytesRead;while ((bytesRead = inputStream.read(buffer)) != -1) {outputStream.write(buffer, 0, bytesRead);}return outputStream.toByteArray();}}
// 主要工具
public void testPicture(){Map<String, Object> datas = new HashMap() {{//本地图片//     put("photo", new PictureRenderData(100, 116, "C:\\Users\\53129\\Pictures\\Saved Pictures\\111.png") );put("name","王首zhen");//  put("oname","");put("sex","男");put("nation","汉族");put("address","天津市");
//				//本地图片byte数据
//				put("localBytePicture", new PictureRenderData(100, 120, ".png", BytePictureUtils.getLocalByteArray(new File("src/test/resources/logo.png"))));
//				//网路图片try {put("photo", new PictureRenderData(100, 100, ".png", testPotPi.getUrlByteArray("https://avatars3.githubusercontent.com/u/1394854?v=3&s=40")));} catch (IOException e) {e.printStackTrace();}
//				// java 图片
//				put("bufferImagePicture", new PictureRenderData(100, 120, ".png", BytePictureUtils.getBufferByteArray(bufferImage)));}};XWPFTemplate template = XWPFTemplate.compile("C:\\Users\\53129\\Desktop\\模板文件.docx").render(datas);FileOutputStream out;try {out = new FileOutputStream("C:\\Users\\53129\\Desktop\\生成文件.docx");template.write(out);out.flush();out.close();template.close();} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

4.测试代码

  public static void main(String[] args) {long l = System.currentTimeMillis();new testPotPi().testPicture();long l1 = System.currentTimeMillis();System.err.println("运行时长"+(l1-l));}

5.封装工具类

   /*tempath :模板文件地址decPath : 生成文件地址*/public static void testPicture(Map<String, Object> datas , String temPath , String decPath){XWPFTemplate template = XWPFTemplate.compile(temPath).render(datas);FileOutputStream out;try {out = new FileOutputStream(decPath);template.write(out);out.flush();out.close();template.close();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}


 

http://www.tj-hxxt.cn/news/31974.html

相关文章:

  • 太原做网站直通车线上推广策划方案
  • 即墨做砍价小程序最好的网站域名注册免费
  • 做企业网站好处个人接外包项目平台
  • html5 网站框架公司网站制作网络公司
  • wordpress强行全站https郑州seo顾问阿亮
  • 成都网站关键排名北京seo报价
  • 做网站推广费用如何优化网站
  • 软件开发和网站建设哪个好天津seo公司
  • 专业餐饮vi设计公司seo营销推广平台
  • 邢台seo一站式长沙网络营销咨询费用
  • 网站设计与网页配色实例精讲厦门seo推广公司
  • 网站怎么加入百度网盟免费推广方式有哪些
  • 网站后台费用外媒头条最新消息
  • 天眼查企业查询在线官网优化网站seo公司
  • 帮别人设计网站电子商务网站
  • 建筑工程公司注册要求seo基础培训教程
  • 怎么做同学录的网站2345网址导航电脑版官网
  • 各省网站备案时长网络营销顾问工作内容
  • 网页游戏网络游戏优化网站排名解析推广
  • ps做网站导航百度推广售后
  • 营销推广工作内容seo是什么的简称
  • 郑州艾特网站建设专业培训大全
  • wordpress建站流量网络营销有哪几种方式
  • 苏州企业网站建设设计推广app赚佣金平台
  • 响应式 网站建设湖南企业网站建设
  • 哪个nas可以做网站上海十大公关公司排名
  • 网站后台图片并排怎么做互联网推广怎么做
  • 小程序开发公司网站源码下载怎么做一个公司网站
  • 网站建设服务标语网站怎么搭建
  • 做的比较好的意大利网站企业软文范例