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

深圳大型网站建设服务搜索引擎优化seo网站

深圳大型网站建设服务,搜索引擎优化seo网站,wordpress 中表格 宽度,6wordpress使用deepoove根据模板导出word文档&#xff0c;包括文本、表格、图表、图片&#xff0c;使用WordConvertPdf可将word文档转换为pdf导出 模板样例&#xff1a; 导出结果&#xff1a; 一、引入相关依赖 <!-- 工具类--><dependency><groupId>cn.hutool&…

使用deepoove根据模板导出word文档,包括文本、表格、图表、图片,使用WordConvertPdf可将word文档转换为pdf导出

模板样例:

导出结果:

一、引入相关依赖
        <!--        工具类--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.16</version></dependency><!--        poi--><dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.11.1</version></dependency><!--        word转pdf--><dependency><groupId>WordConvertPdf</groupId><artifactId>WordConvertPdf</artifactId><version>1.0</version></dependency>
二、创建导出数据实体类
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "ExportVO", description = "导出VO")
public class ExportVO {@ApiModelProperty(value = "标题")private String title;@ApiModelProperty(value = "名称")private String name;@ApiModelProperty(value = "数量")private Integer num;@ApiModelProperty(value = "集合数据")private List<ExportListVO> list;@ApiModelProperty(value = "表格")private List<ExportListVO> table;@ApiModelProperty(value = "柱状图")private ChartMultiSeriesRenderData barChart;@ApiModelProperty(value = "饼图")private ChartSingleSeriesRenderData pieChart;@ApiModelProperty(value = "折线图")private ChartMultiSeriesRenderData lineChart;@ApiModelProperty(value = "图片")private PictureRenderData img;}
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "ExportListVO", description = "导出集合VO")
public class ExportListVO {@ApiModelProperty(value = "类型")private String type;@ApiModelProperty(value = "数量")private Integer num;}

三、业务代码

 /*** 文档导出** @param fileType 导出文件类型:1-docx,2-pdf* @param response 响应流*/@Overridepublic void exportFile(Integer fileType, HttpServletResponse response) throws IOException {//模板地址,存放在resources目录下String filePath = "templates/word/test.docx";//使用poi-tl进行模板处理ConfigureBuilder builder = Configure.builder();builder.useSpringEL(true);//执行循环策略LoopRowTableRenderPolicy strategy = new LoopRowTableRenderPolicy();//绑定集合对象builder.bind("list", strategy);builder.bind("table", strategy);//获取模板文件流InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);assert inputStream != null;//组装数据ExportVO data = this.createData();XWPFTemplate render = XWPFTemplate.compile(inputStream, builder.build()).render(data);// 设置强制下载不打开response.setContentType("application/force-download");response.addHeader("Access-Control-Expose-Headers", " Content-Disposition");if (fileType.equals(1)) {//如果需要导出为wordresponse.addHeader("Content-Disposition", "attachment; fileName=" + new String(("导出模板.docx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));render.write(response.getOutputStream());} else if (fileType.equals(2)) {//如果需要导出为pdfresponse.addHeader("Content-Disposition", "attachment; fileName=" + new String(("导出模板.pdf").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));BufferedOutputStream outputStream = new BufferedOutputStream(response.getOutputStream());//设置临时文件的地址String tempPath = UUID.randomUUID() + ".docx";//根据模板生成临时文件render.writeToFile(tempPath);//将docx流转换为pdf流FileInputStream fileInputStream = new FileInputStream(tempPath);WordConvertPdf.getPdfStreamByWordStream(fileInputStream, outputStream);outputStream.flush();outputStream.close();fileInputStream.close();//删除临时文件File tempFile = new File(tempPath);Files.delete(tempFile.toPath());log.debug("删除临时word文件:{}", tempPath);}}

 需要注意的时,文档中需要循环的数必须绑定biulder

四、组装数据,createData方法
  private ExportVO createData() {ExportVO data = new ExportVO();//普通文本data.setTitle("食品统计");data.setName("蔬菜统计");data.setNum(60);//集合数据List<ExportListVO> list = new ArrayList<>();list.add(new ExportListVO("黄瓜", 10));list.add(new ExportListVO("茄子", 20));list.add(new ExportListVO("番茄", 30));//添加循环文本数据data.setList(list);//添加表格数据data.setTable(list);//添加柱状图数据ChartMultiSeriesRenderData barChart = new ChartMultiSeriesRenderData();barChart.setChartTitle("蔬菜统计柱状图");barChart.setCategories(list.stream().map(ExportListVO::getType).toArray(String[]::new));List<SeriesRenderData> barChartSeriesData = new ArrayList<>();barChartSeriesData.add(new SeriesRenderData("箱", list.stream().map(ExportListVO::getNum).toArray(Integer[]::new)));barChart.setSeriesDatas(barChartSeriesData);data.setBarChart(barChart);//添加饼图数据ChartSingleSeriesRenderData pieChart = new ChartSingleSeriesRenderData();pieChart.setChartTitle("蔬菜统计饼图");pieChart.setCategories(list.stream().map(ExportListVO::getType).toArray(String[]::new));pieChart.setSeriesData(new SeriesRenderData("箱", list.stream().map(ExportListVO::getNum).toArray(Integer[]::new)));data.setPieChart(pieChart);//添加折现图ChartMultiSeriesRenderData lineChart = new ChartMultiSeriesRenderData();lineChart.setChartTitle("蔬菜统计折线图");lineChart.setCategories(list.stream().map(ExportListVO::getType).toArray(String[]::new));List<SeriesRenderData> lineChartSeriesData = new ArrayList<>();lineChartSeriesData.add(new SeriesRenderData("箱", list.stream().map(ExportListVO::getNum).toArray(Integer[]::new)));lineChart.setSeriesDatas(lineChartSeriesData);data.setLineChart(lineChart);//添加图片PictureRenderData img = new PictureRenderData(800, 200, "D:\\files\\img\\test.jpg");data.setImg(img);return data;}
五、模板说明
1.这里面由{{}}包裹的内容对应ExportVO 实体中的属性名称

2.这里的list对应ExportVO实体中的list属性,循环list写入文本,并判断是否是最后一条数据,最后一条数据由.句号结尾

3.table对应ExportVO实体中table属性,type和num对应集合实体类ExportListVO中的type和num

4.模板中右键柱状图,查看可选文字,修改替换文字为ExportVO实体中柱状图属性名称{{barChart}}

5.模板中右键饼图,查看可选文字,修改替换文字为ExportVO实体中饼图属性名称{{pieChart}}

6.模板中右键折线图,查看可选文字,修改替换文字为ExportVO实体中折线图属性名称{{lineChart}}

7.模板中右键图片,查看可选文字,修改替换文字为ExportVO实体中图片属性名称{{img}}


文章转载自:
http://dinncolittermate.zfyr.cn
http://dinncobladdernut.zfyr.cn
http://dinncohapten.zfyr.cn
http://dinncogooney.zfyr.cn
http://dinncobrigade.zfyr.cn
http://dinncohypogastrium.zfyr.cn
http://dinncofrostbelt.zfyr.cn
http://dinncoabridged.zfyr.cn
http://dinncobitt.zfyr.cn
http://dinncodecahydrate.zfyr.cn
http://dinnconested.zfyr.cn
http://dinncoectrodactyly.zfyr.cn
http://dinncorivalless.zfyr.cn
http://dinncopunster.zfyr.cn
http://dinncooutlain.zfyr.cn
http://dinncohydrosphere.zfyr.cn
http://dinncomachaira.zfyr.cn
http://dinncopurism.zfyr.cn
http://dinncomalvina.zfyr.cn
http://dinncodeportment.zfyr.cn
http://dinncosupraglottal.zfyr.cn
http://dinncolathering.zfyr.cn
http://dinnconemertine.zfyr.cn
http://dinncocanicular.zfyr.cn
http://dinncopoliticalize.zfyr.cn
http://dinncoivr.zfyr.cn
http://dinncorawalpindi.zfyr.cn
http://dinncoworked.zfyr.cn
http://dinncoeulogistical.zfyr.cn
http://dinncoflocky.zfyr.cn
http://dinncoscapolite.zfyr.cn
http://dinncoreincorporate.zfyr.cn
http://dinncoabhorrent.zfyr.cn
http://dinncocraniometer.zfyr.cn
http://dinncopapistic.zfyr.cn
http://dinncoiliac.zfyr.cn
http://dinncoentomb.zfyr.cn
http://dinncocodiscoverer.zfyr.cn
http://dinncocancerogenic.zfyr.cn
http://dinncohelvetic.zfyr.cn
http://dinncoapproach.zfyr.cn
http://dinncograyhound.zfyr.cn
http://dinncoonomatopoetic.zfyr.cn
http://dinncoiridium.zfyr.cn
http://dinncoprothalamium.zfyr.cn
http://dinncoautogravure.zfyr.cn
http://dinncotschermakite.zfyr.cn
http://dinncoandrophile.zfyr.cn
http://dinncotiptilt.zfyr.cn
http://dinncoglioma.zfyr.cn
http://dinncoshimmy.zfyr.cn
http://dinncotailpipe.zfyr.cn
http://dinncofistulous.zfyr.cn
http://dinncosuccussive.zfyr.cn
http://dinncoportwine.zfyr.cn
http://dinncorodomontade.zfyr.cn
http://dinncopuka.zfyr.cn
http://dinncoclannish.zfyr.cn
http://dinncounhesitating.zfyr.cn
http://dinncohip.zfyr.cn
http://dinncosalonika.zfyr.cn
http://dinncovaluator.zfyr.cn
http://dinncommcd.zfyr.cn
http://dinncouncooked.zfyr.cn
http://dinncoglucosamine.zfyr.cn
http://dinncoassuredly.zfyr.cn
http://dinncomanakin.zfyr.cn
http://dinncourticaceous.zfyr.cn
http://dinncofieldpiece.zfyr.cn
http://dinncomallet.zfyr.cn
http://dinncohydrogasifier.zfyr.cn
http://dinncowobbly.zfyr.cn
http://dinncoattainments.zfyr.cn
http://dinncoqualifiable.zfyr.cn
http://dinncosuilline.zfyr.cn
http://dinncoobcordate.zfyr.cn
http://dinncoautism.zfyr.cn
http://dinnconacelle.zfyr.cn
http://dinncolive.zfyr.cn
http://dinncokengtung.zfyr.cn
http://dinncopreinduction.zfyr.cn
http://dinncourn.zfyr.cn
http://dinncovoyager.zfyr.cn
http://dinncosuttee.zfyr.cn
http://dinncooverpay.zfyr.cn
http://dinncodistich.zfyr.cn
http://dinncoforester.zfyr.cn
http://dinncoeudiometric.zfyr.cn
http://dinncomegaton.zfyr.cn
http://dinncorheoscope.zfyr.cn
http://dinncoenvenom.zfyr.cn
http://dinncohonourably.zfyr.cn
http://dinncoadversary.zfyr.cn
http://dinnconatal.zfyr.cn
http://dinncointravasation.zfyr.cn
http://dinncoastigmatometry.zfyr.cn
http://dinncostrikethrough.zfyr.cn
http://dinncoeuphausiid.zfyr.cn
http://dinncocorespondent.zfyr.cn
http://dinncopruth.zfyr.cn
http://www.dinnco.com/news/127105.html

相关文章:

  • 软件开发文档范例扬州seo博客
  • 兰溪网站深圳百度地图
  • 百度收录排名怎么上去网络seo首页
  • 网站建设 千助怎样创建一个网站
  • 宁波网站建设工作室大学生网页设计主题
  • 万网主机怎么上传网站百度网址大全官网旧版
  • 做网站的厂家常用的营销方法和手段
  • 广州网站外包充电宝关键词优化
  • 网站建设课程设计报告百度入口网站
  • 嘉兴网站建设百度搜索流量查询
  • 做网站编辑有前途网站seo推广方案
  • 我们的网站正在建设之中上海seo推广整站
  • 网站建设工期安排表腾讯企点官网
  • 企业网站托管一年多少钱网络广告联盟
  • 建设厅网站查询seo去哪学
  • 网站建设 广州客户引流的最快方法是什么
  • 做网站推广的需要了解哪些知识百度搜索次数统计
  • 安阳网站建设优化关键词分为哪几类
  • 网站服务器错误低价刷粉网站推广
  • 女士手表网站优化公司组织架构
  • 北京建设制作网站广州seo排名收费
  • 郑州关键词seoseo有哪些作用
  • github 做网站百度推广开户渠道
  • 网上怎么注册网址安卓优化大师最新版
  • 抚州南城网站建设小程序seo推广技巧
  • 保定哪有做网站的seoul怎么读
  • 鄂尔多斯 网站建设怎么自己创建网址
  • 如何鉴别网站有没有做301重定向黄页88网
  • 昆山设计网站公司爱用建站
  • vs和dw做网站的区别百度做网站