VUE导出文本以及echarts图表到word文档(docxtemplater)

使用插件 docxtemplater

docxtemplater官网:Docxtemplater | Word, Powerpoint, Excel generation using templates in your application | docxtemplater

 下载并引入相关包:

npm i docxtemplater pizzip  --save
npm i jszip-utils --save 
npm i jszip --save
npm i file-saver --save


import PizZip from 'pizzip'
import docxtemplater from 'docxtemplater'
import JSZipUtils from 'jszip-utils'
import { saveAs } from 'file-saver'

具体实现参考下文:

 参考:vue导出echarts图表及文本到word_方某某的博客-CSDN博客_vue导出echarts图

文档模板如下:

渲染规则:

模板渲染规则
//单个变量模板中直接用{}
{ename}

//循环{#xbImg} {/xbImg}
const xbImg = [
    { index : 1, url : 'XXXXXXX.png' },
    { index : 2, url : 'XXXXXXX.png' },
    { index : 3, url : 'XXXXXXX.png' }
]


{#xbImg} 

第{index }张图片:{%url}

{/xbImg}


//图片{%}   
{%gpImg}

//图片居中{%%}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值