我欲封天 耳根 小说零,玄幻小说排行榜 http://marshallsonline.cn/tag/nodejs/ zh-CN Tue, 16 Nov 2021 09:34:00 +0800 Tue, 16 Nov 2021 09:34:00 +0800 nodejs 生成 word officegen模塊使用方法 http://marshallsonline.cn/inews/n3/officegen.html http://marshallsonline.cn/inews/n3/officegen.html Tue, 16 Nov 2021 09:34:00 +0800 admin 詳細(xì)文檔鏈接

https://github.com/Ziv-Barber/officegen/blob/87dd5501968501555ea3bee60043affc9f67c1fa/manual/docx/README.md

引用

const officegen = require('officegen');

監(jiān)聽

docx.on('finalize', function(written) {
   console.log(
     'Finish to create a Microsoft Word document.'
   );
});

// Officegen calling this function to report errors:
docx.on('error', function(err) {
  console.log(err);
});
out.on('error', function(err) {
  console.log(err);
});

生成一行

let pObj = docx.createP();

行內(nèi)添加文字元素

pObj.addText(' and back color.', { color: '00ffff', back: '000088',shdType: 'pct12',shdColor: 'ff0000' ,link: 'https://github.com'});

設(shè)置文字對齊方式

pObj.options.align = 'right';

關(guān)聯(lián)文件并導(dǎo)出

const out = fs.createWriteStream('./app/public/example.docx');
docx.generate(out);
]]>
0 http://marshallsonline.cn/inews/n3/officegen.html#comments http://marshallsonline.cn/feed/tag/nodejs/
mongoose 多表查詢 使用條件查詢 http://marshallsonline.cn/inews/n3/16.html http://marshallsonline.cn/inews/n3/16.html Mon, 21 Jun 2021 12:16:00 +0800 admin aggregate.push({ $lookup: { from: 'examnum', let: { userId: '$_id' }, pipeline: [ { $match: { $expr: { $eq: [ '$exambatchId', mongoose.Types.ObjectId(data.exambatchId) ], }, }, }, { $match: { $expr: { $eq: [ '$userId', '$$userId' ], }, }, }, { $sort: { _id: 1 }, }, { $limit: 1, }, ], as: 'examnum', }, }); ]]> 0 http://marshallsonline.cn/inews/n3/16.html#comments http://marshallsonline.cn/feed/tag/nodejs/