为了创建word文档,我使用officegen包:
var fs = require('fs');
var officegen = require('officegen');
var docx = officegen ({
'type': 'docx',
'title': 'test title'
})
var pObj = docx.createP ();
pObj.addText('Text');
pObj.addText('with color', {color: '000088'});
pObj.addText('and back color.', {color: '00ffff',back: '000088'});
var out = fs.createWriteStream(__dirname + '/tmp/out.docx');
docx.generate(out)
out.on('error', function(err) {
console.log('out error: ' + err);
});
docx.on('finalize', function(written) {
console.log('Finish to create a Word file.\nTotal bytes created: ' + written + '\n');
});
docx.on('error', function(err) {
console.log('docx appeared: ' + err);
});
会发生什么:
File get created, with content 'PK'
为什么?
控制台中抛出错误:
Cannot read property 'pipesCount' of undefined
之前有人遇到过这个问题吗?
问候和感谢