【发布时间】:2020-12-02 04:31:59
【问题描述】:
主要问题:我想在 Microsoft Word 文档中插入 40 多个文本。 通过java脚本代码:
// requiring modules
const fs = require('fs'),
docx = require('docx');
// create a new doc
const doc = new docx.Document();
// get paragraph text
const getData = new docx.Paragraph({
children:[
new docx.TextRun({
text: 'Welcome from getData',
size: 72
}),
],
})
//add a section to document to render the paragraph
doc.addSection({
children:[
getData
]
});
//write the buffer to the file.docx
docx.Packer.toBuffer(doc).then((Buffer)=>{
fs.writeFileSync("text.docx" , Buffer);
})
我尝试了所有方法,但没有任何效果。
【问题讨论】:
标签: javascript node.js npm node-modules docx