VUE+docxtemplater来处理word模板
引入JSword模板用word制作模板,例如:模板内容:编写代码exportWord() {const { baseInfo } = this.formJSZipUtils.getBinaryContent('index.docx', (error, content) => {console.log('error = ', error, content)const zip = new Piz
·
引入JS
word模板
用word制作模板,例如:
模板内容:
编写代码
exportWord() {
const { baseInfo } = this.form
JSZipUtils.getBinaryContent('index.docx', (error, content) => {
console.log('error = ', error, content)
const zip = new PizZip(content)
const doc = new docxtemplater()
doc.loadZip(zip)
doc.setData(baseInfo)
try {
doc.render()
} catch (error) {
const e = {
message: error.message,
name: error.name,
stack: error.stack,
properties: error.properties
}
throw error
}
const out = doc.getZip().generate({
type: 'blob',
mimeType:
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
})
saveAs(out, '个人电子档案.docx')
})
},
更多推荐
已为社区贡献5条内容
所有评论(0)