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

陕西金顶建设公司网站在婚恋网站做销售好吗

陕西金顶建设公司网站,在婚恋网站做销售好吗,好的建站软件,百度app免费下载安装第076个 查看专栏目录: VUE 本文章目录 示例说明示例效果图导出的文件效果截图示例源代码参数说明:重要提示:API 参考网址 示例说明 在Vue中导出Word文档,可以使用第三方库file-saver和html-docx-js。首先需要安装这两个库: npm …

在这里插入图片描述

第076个

查看专栏目录: VUE


本文章目录

    • 示例说明
    • 示例效果图
    • 导出的文件效果截图
    • 示例源代码
    • 参数说明:
    • 重要提示:
    • API 参考网址

示例说明

在Vue中导出Word文档,可以使用第三方库file-saver和html-docx-js。首先需要安装这两个库:

npm install file-saver html-docx-js --save

然后在Vue组件中使用这两个库来导出Word文档:

示例效果图

在这里插入图片描述

导出的文件效果截图

在这里插入图片描述

示例源代码

/*
* @Author: 大剑师兰特(xiaozhuanlan),还是大剑师兰特(CSDN)
* @此源代码版权归大剑师兰特所有,可供学习或商业项目中借鉴,未经授权,不得重复地发表到博客、论坛,问答,git等公共空间或网站中。
* @Email: 2909222303@qq.com
* @weixin: gis-dajianshi
* @First published in CSDN
* @First published time: 2024-02-16
*/<template><div class="djs-box"><div class="topBox"><h3>vue导出word文档</h3><div>大剑师兰特, 还是大剑师兰特,gis-dajianshi</div><h4><el-button type="primary" size="mini" @click="exportToWord()"> 导出word文档</el-button></h4></div><div class="dajianshi" id="dajianshi"><h3> 这是我要导出的文件标题</h3><p>This is a very small library that is capable of converting HTML documents to DOCX format that is used byMicrosoft Word 2007 and onward. It manages to perform the conversion in the browser by using a featurecalled 'altchunks'. In a nutshell, it allows embedding content in a different markup language. We areusing MHT document to ship the embedded content to Word as it allows to handle images. After Word openssuch file, it converts the external content to Word Processing ML (this is how the markup language ofDOCX files is called) and replaces the reference.</p><p>Altchunks were not supported by Microsoft Word for Mac 2008 and are not supported by LibreOffice andGoogle Docs.</p></div></div>
</template><script>import FileSaver from 'file-saver';import htmlDocx from 'html-docx-js/dist/html-docx';export default {data() {return {message: 'hello world',price: 1234.56,date: '2022-01-01'}},methods: {exportToWord() {// 获取要导出的HTML内容const content = document.getElementById('dajianshi').innerHTML;// 将HTML内容转换为Word文档const converted = htmlDocx.asBlob(content);// 使用FileSaver保存Word文档FileSaver.saveAs(converted, 'example.docx');},},}
</script>
<style scoped>.djs-box {width: 1000px;height: 650px;margin: 50px auto;border: 1px solid deepskyblue;}.topBox {margin: 0 auto 0px;padding: 10px 0 20px;background: deepskyblue;color: #fff;}.dajianshi {width: 93%;height: 400px;margin: 5px auto 0;border: 1px solid #369;background-color: cde;padding: 20px;}p {font-size: 16px;text-align: left;}
</style>

参数说明:

要生成 DOCX,只需将 HTML 文档(作为字符串)传递给 asBlob 方法以接收包含输出文件的 Blob(或缓冲区)。

var converted = htmlDocx.asBlob(content);
saveAs(converted, ‘test.docx’);

asBlob 可以采用其他选项来控制文档的页面设置

orientation: landscape or portrait (default)
margins: map of margin sizes (expressed in twentieths of point, see WordprocessingML documentation for details):
top: number (default: 1440, i.e. 2.54 cm)
right: number (default: 1440)
bottom: number (default: 1440)
left: number (default: 1440)
header: number (default: 720)
footer: number (default: 720)
gutter: number (default: 0)

重要提示:

please pass a complete, valid HTML (including DOCTYPE, html and body tags). This may be less convenient, but gives you possibility of including CSS rules in style tags.

html-docx-js is distributed as ‘standalone’ Browserify module (UMD). You can require it as html-docx. If no module loader is available, it will register itself as window.htmlDocx. See test/sample.html for details.

API 参考网址

https://www.npmjs.com/package/html-docx-js

http://www.hyszgw.com/news/36446.html

相关文章:

  • 佛山贸易网站建设网站怎么做图片动态图片
  • 黑龙江专业建站黄做网站
  • 建站用什么工具小牛在线网站建设
  • 南阳市做网站手机wap网站多少钱
  • 怎么做自己下单的网站淘宝上有做网站的吗
  • 国家关于网站信息建设管理文件网站栏目设置完整度建设
  • 学校网站 网站建设企业网站开发douyanet
  • 什么网站做装修公司广告比较好搜索引擎网站建设公司
  • 怎样做展示型网站山西网站建设制作推广
  • 企业网站四种类型上海互联网推广找哪家
  • 深圳做网站那家好网站 微信小程序怎么做
  • 石家庄模板网站做网站可以用php
  • 厦门孚珀科技 网站开发个人可以做建站网站么
  • 宝山顺德网站建设学网站开发如何挣钱
  • php网站建设心得体会怎么建立微信公众号平台
  • 百度网站建设社区电商平台排行榜
  • 提供网站建设的理由wordpress文章添加自定义字段
  • 交通运输行业网站建设东莞常平招聘信息
  • 建设医疗网站seo短视频加密路线
  • 深圳网站制作公司流程品牌整合营销传播方案
  • c 网站建设步骤360网址
  • 校园门户网站开发需求分析二级域名可以做网站
  • 丰台怎样做网站软件ui设计怎么做网站
  • 域名注册后 免费自建网站手机关联网站
  • 几大门户网站云购网站做的起来吗
  • 公司介绍网站模板wordpress如何建目录
  • 做外贸网站咨询做网站需要多少钱 百度
  • 网站后台建设内容做食品生产的网站
  • 网站成立时间查询西安优秀的集团门户网站建设费用
  • 扁平化设计网站sem推广竞价