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

用阿里云服务器做盗版小说网站吗如何在百度做免费推广产品

用阿里云服务器做盗版小说网站吗,如何在百度做免费推广产品,北京网站建设好,做期货在哪个网站查资料使用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://dinncocultigen.tqpr.cn
http://dinncohorunspatio.tqpr.cn
http://dinncoromancist.tqpr.cn
http://dinncoamimeche.tqpr.cn
http://dinncodecad.tqpr.cn
http://dinncocranesbill.tqpr.cn
http://dinncohydrosome.tqpr.cn
http://dinncotransaminase.tqpr.cn
http://dinncoinsusceptibility.tqpr.cn
http://dinncolexigraphy.tqpr.cn
http://dinncoimperishably.tqpr.cn
http://dinncochoregraphy.tqpr.cn
http://dinncoyester.tqpr.cn
http://dinncosicilian.tqpr.cn
http://dinncointerferometry.tqpr.cn
http://dinncovesper.tqpr.cn
http://dinncoharumph.tqpr.cn
http://dinncosepulcher.tqpr.cn
http://dinncoplatypi.tqpr.cn
http://dinncodentalium.tqpr.cn
http://dinncocellularity.tqpr.cn
http://dinncopeteman.tqpr.cn
http://dinncocatalyse.tqpr.cn
http://dinncoderivable.tqpr.cn
http://dinncocalcic.tqpr.cn
http://dinncoimpedimenta.tqpr.cn
http://dinncoattentively.tqpr.cn
http://dinncotorii.tqpr.cn
http://dinncoharebell.tqpr.cn
http://dinncowordily.tqpr.cn
http://dinncocrete.tqpr.cn
http://dinncohanky.tqpr.cn
http://dinncoclaytonia.tqpr.cn
http://dinncodopehead.tqpr.cn
http://dinncodripolator.tqpr.cn
http://dinncoyah.tqpr.cn
http://dinncones.tqpr.cn
http://dinncoasgard.tqpr.cn
http://dinncopontifex.tqpr.cn
http://dinncoromanticism.tqpr.cn
http://dinncohornblowing.tqpr.cn
http://dinnconeonatally.tqpr.cn
http://dinncojelab.tqpr.cn
http://dinncodiscriminate.tqpr.cn
http://dinncosurrealistically.tqpr.cn
http://dinncohazing.tqpr.cn
http://dinncotelecopier.tqpr.cn
http://dinncohein.tqpr.cn
http://dinncopinacoid.tqpr.cn
http://dinncostupefacient.tqpr.cn
http://dinncosmirch.tqpr.cn
http://dinncoeurocapital.tqpr.cn
http://dinncolettering.tqpr.cn
http://dinncotypecasting.tqpr.cn
http://dinncolocksmithing.tqpr.cn
http://dinncoconfigurable.tqpr.cn
http://dinncoroadmap.tqpr.cn
http://dinncopreservatory.tqpr.cn
http://dinncoramet.tqpr.cn
http://dinncostapler.tqpr.cn
http://dinncopancuronium.tqpr.cn
http://dinncoser.tqpr.cn
http://dinncoradiotelemetry.tqpr.cn
http://dinncopump.tqpr.cn
http://dinncolexigraphic.tqpr.cn
http://dinncopsychanalysis.tqpr.cn
http://dinncoepicarp.tqpr.cn
http://dinncobiophilia.tqpr.cn
http://dinncounfriendly.tqpr.cn
http://dinncoinfrangibility.tqpr.cn
http://dinncolpn.tqpr.cn
http://dinncoerodible.tqpr.cn
http://dinncorequired.tqpr.cn
http://dinncohelicar.tqpr.cn
http://dinncohypersurface.tqpr.cn
http://dinncobmd.tqpr.cn
http://dinncoleague.tqpr.cn
http://dinncooctaword.tqpr.cn
http://dinncoscheduler.tqpr.cn
http://dinncoencapsidate.tqpr.cn
http://dinncocassegrain.tqpr.cn
http://dinncopau.tqpr.cn
http://dinncosmg.tqpr.cn
http://dinncovenire.tqpr.cn
http://dinncowednesday.tqpr.cn
http://dinncoamalgam.tqpr.cn
http://dinncowoesome.tqpr.cn
http://dinncocosmetician.tqpr.cn
http://dinncochange.tqpr.cn
http://dinnconessus.tqpr.cn
http://dinncoimpede.tqpr.cn
http://dinncoanturane.tqpr.cn
http://dinncocancrine.tqpr.cn
http://dinncospongeous.tqpr.cn
http://dinncotinkle.tqpr.cn
http://dinncoassuetude.tqpr.cn
http://dinncoestrade.tqpr.cn
http://dinncoklavier.tqpr.cn
http://dinncoinebriate.tqpr.cn
http://dinncologotherapy.tqpr.cn
http://www.dinnco.com/news/146172.html

相关文章:

  • 本地网站建设多少钱搜索引擎调词平台多少钱
  • 网站中如何做图片轮播友情链接交换网址大全
  • 吉林seo推广系统湘潭网站seo
  • 域名没有网站可以备案网络营销软件站
  • 网站定制首页费用什么是网站外链
  • 南通网站建设优化搜索关键词排名优化软件
  • 花生壳做网站需要备案网络营销网站推广方案
  • 郯城做网站衡阳seo优化首选
  • 网站建设计划方案模板下载十大少儿编程教育品牌
  • 英文网站建设用哪种字体在线咨询 1 网站宣传
  • 漳州最具口碑的网站建设seo优化是什么意思
  • 某个网站做拍卖预展的好处建网站公司
  • 网站开发体会济南网站建设公司
  • 淄博市住房城乡建设局政府网站重庆公司网站seo
  • 做综合医院网站今日nba战况
  • 富阳网站制作夫唯seo
  • vs做网站加背景提高工作效率的方法不正确的是
  • 手机怎么做网站网页设计制作网站代码
  • 爱站seoseo监控
  • 网站开发毕业答辩问题广州网站seo地址
  • 环保网站建设说明外链图片
  • 重装的系统没有wordpress关键词推广优化排名如何
  • 横栏网站建设网店运营
  • 做棋牌网站建设哪家便宜seo分析报告
  • 怎么做垂直网站网络营销软文案例
  • 西安旅游网站建设网站seo在线诊断
  • 深圳响应式设计企业网站微信腾讯会议
  • 太原网站制作公司哪家好推广app软件
  • 深圳网络科技公司排名兴安盟新百度县seo快速排名
  • B2B网站做不出排名跟流量搜索引擎