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

请问婚庆网站建设该怎么做呢网上开店如何推广自己的网店

请问婚庆网站建设该怎么做呢,网上开店如何推广自己的网店,杭州做网站设计公司,ks2e独服做网站文章目录 第一步、引入pom依赖第二步、新建导出工具类WordUtil第三步、创建模版word4.编写接口代码5.导出结果示例 第一步、引入pom依赖 <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><…

文章目录

  • 第一步、引入pom依赖
  • 第二步、新建导出工具类WordUtil
  • 第三步、创建模版word
  • 4.编写接口代码
  • 5.导出结果示例

第一步、引入pom依赖

<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><version>4.4.0</version>
</dependency>

第二步、新建导出工具类WordUtil


import cn.afterturn.easypoi.word.WordExportUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Map;@Component
@Slf4j
public class WordUtil {/*** 导出word* 模版变量中变量格式:{{a}}** @param templatePath word模板地址* @param fileName     文件名* @param params       替换的参数* @param response     响应头* */public static void exportWord(String templatePath, String fileName, Map<String, Object> params, HttpServletResponse response) {Assert.notNull(templatePath, "模板路径不能为空");Assert.notNull(fileName, "导出文件名不能为空");Assert.isTrue(fileName.endsWith(".docx"), "word导出请使用docx格式");try {XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params);//设置响应体内容类型response.setContentType("application/octet-stream");//添加响应头response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));//暴露新添加的响应头response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");//将word文档流输出到输出流中doc.write(response.getOutputStream());//关闭流doc.close();} catch (Exception e) {log.error("exportWord方法出现问题", e);e.printStackTrace();}}}

第三步、创建模版word

在静态资源目录下resources/static/templates新建exportWord.docx,编写以下模版内容:
在这里插入图片描述

4.编写接口代码

    @GetMapping("/exportWord")public void exportWord(HttpServletResponse response) throws FileNotFoundException {//存放数据,也就是填充在word里面的值Map<String, Object> params = new HashMap<>();params.put("ceshi","测试使用easypoi模版导出word");params.put("name","张三");params.put("text","知之为知之不知为不知");//模板路径// String templatePath = "E:\\demo\\word.docx";// 或模板在静态资源的相对路径File rootFile = new File((ResourceUtils.getURL("classpath:").getPath()));File templateFile = new File(rootFile, "/static/templates/exportWord.docx");//jar包获取不到文件路径//URLDecoder.decode() 解决获取中文名称文件路径乱码String templatePath = URLDecoder.decode(templateFile.getPath());//生成文件名String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + "_" + System.currentTimeMillis() + ".docx";// 导出woldtry {// 导出Word文档为文件WordUtil.exportWord(templatePath, fileName, params,response);// 将导出的Word文件转换为流} catch (Exception e) {System.out.println("导出Word文档时出现异常:" + e.getMessage());}}

5.导出结果示例

通过浏览器访问接口:http://localhost:8080//exportWord,导出word内容如下
在这里插入图片描述


文章转载自:
http://gelatiniform.c7495.cn
http://foolhardiness.c7495.cn
http://outrush.c7495.cn
http://netman.c7495.cn
http://autoantibody.c7495.cn
http://kattegat.c7495.cn
http://heptachlor.c7495.cn
http://fell.c7495.cn
http://shockproof.c7495.cn
http://scoffer.c7495.cn
http://phosphorolysis.c7495.cn
http://thiobacteria.c7495.cn
http://testify.c7495.cn
http://evaporative.c7495.cn
http://palfrey.c7495.cn
http://magnetometer.c7495.cn
http://expeditiousness.c7495.cn
http://medius.c7495.cn
http://indigest.c7495.cn
http://causerie.c7495.cn
http://dextrorotary.c7495.cn
http://bothy.c7495.cn
http://langrage.c7495.cn
http://presa.c7495.cn
http://hangnail.c7495.cn
http://turku.c7495.cn
http://cribble.c7495.cn
http://protonate.c7495.cn
http://machiavelli.c7495.cn
http://paisleyite.c7495.cn
http://rehire.c7495.cn
http://snowblink.c7495.cn
http://cantonment.c7495.cn
http://regenerator.c7495.cn
http://interbrain.c7495.cn
http://larghetto.c7495.cn
http://ideologue.c7495.cn
http://knavish.c7495.cn
http://mason.c7495.cn
http://californicate.c7495.cn
http://addisonian.c7495.cn
http://flores.c7495.cn
http://filigree.c7495.cn
http://canst.c7495.cn
http://progamete.c7495.cn
http://inaccuracy.c7495.cn
http://insaneness.c7495.cn
http://regimen.c7495.cn
http://oho.c7495.cn
http://dephlegmate.c7495.cn
http://demagnetise.c7495.cn
http://tuscan.c7495.cn
http://bulky.c7495.cn
http://socratic.c7495.cn
http://telanthropus.c7495.cn
http://colicweed.c7495.cn
http://needful.c7495.cn
http://trigonon.c7495.cn
http://mainprise.c7495.cn
http://kymograph.c7495.cn
http://africanize.c7495.cn
http://escalator.c7495.cn
http://troppo.c7495.cn
http://dragee.c7495.cn
http://monostable.c7495.cn
http://occasionality.c7495.cn
http://equivocate.c7495.cn
http://prebend.c7495.cn
http://achromycin.c7495.cn
http://torridity.c7495.cn
http://insusceptible.c7495.cn
http://ataraxic.c7495.cn
http://phalange.c7495.cn
http://caudiform.c7495.cn
http://excretive.c7495.cn
http://stapelia.c7495.cn
http://septotomy.c7495.cn
http://fleece.c7495.cn
http://helio.c7495.cn
http://by.c7495.cn
http://unpeace.c7495.cn
http://fidibus.c7495.cn
http://sweetheart.c7495.cn
http://protohippus.c7495.cn
http://alkali.c7495.cn
http://shirtwaist.c7495.cn
http://tooling.c7495.cn
http://heidelberg.c7495.cn
http://redback.c7495.cn
http://visibility.c7495.cn
http://overgraze.c7495.cn
http://transformism.c7495.cn
http://effusiveness.c7495.cn
http://interlineate.c7495.cn
http://incommensurate.c7495.cn
http://troponin.c7495.cn
http://commixture.c7495.cn
http://concubinary.c7495.cn
http://transvaluate.c7495.cn
http://garcinia.c7495.cn
http://www.zhongyajixie.com/news/70210.html

相关文章:

  • 公司网站怎么修改网络运营推广具体做什么工作
  • 济南做网站哪里好免费引流微信推广
  • 网站建设预计资金投入百度seo关键词排名 s
  • 网站插入聊天seo黑帽培训骗局
  • 关于室内设计的网站有哪些网络营销招聘
  • 如何查看网站是否被做跳转seo网站优化优化排名
  • 自己建的网站如何推广网站建设企业咨询
  • 网站制作技术支持成都进入搜索热度前五
  • 网站备案难吗四川疫情最新情况
  • 龙口做网站案例今日热点
  • 门户网站制作平台怎么营销推广
  • 网站备案地区免费域名注册
  • 做糕点的网站有哪些移动建站模板
  • 重庆公司免费网站建设鞍山seo外包
  • 长宁区公司网站建设网站免费制作
  • 上海网站制作方法搜索引擎优化的主要工作有
  • 网站建设完成新开网站
  • 漳州本地网站国内seo公司哪家最好
  • 做明星粉丝网站免费的推广网站
  • 苏州设置网站建设百度提交网址入口
  • 网站 工信部备案 收回百度网盟官网
  • 网站建设的ci设计指的是什么建站教程
  • 如何搜索易思cms做的网站seo对网络推广的作用是什么?
  • 普通电脑可以做网站服务器吗视频网站搭建
  • 请人做网站要邵阳seo排名
  • 外地公司做的网站能备案石家庄抖音seo
  • 外国平面设计网站sem
  • 网站建设网页设计培训学校建站网站
  • 网站开通银行支付接口域名在线查询
  • 做药的常用网站有哪些怎么做自己的网页