如何使用Node.js创建Excel文件?

如何使用Node.js创建Excel文件?,第1张

如何使用Node.js创建Excel文件

excel4node是 根据官方规范构建的
本地Excel文件维护者。它与另一个答案中提到的mxexcel-
builder
相似,但维护性更高。

// Require libraryvar excel = require('excel4node');// Create a new instance of a Workbook classvar workbook = new excel.Workbook();// Add Worksheets to the workbookvar worksheet = workbook.addWorksheet('Sheet 1');var worksheet2 = workbook.addWorksheet('Sheet 2');// Create a reusable stylevar style = workbook.createStyle({  font: {    color: '#FF0800',    size: 12  },  numberFormat: '$#,##0.00; ($#,##0.00); -'});// Set value of cell A1 to 100 as a number type styled with paramaters of styleworksheet.cell(1,1).number(100).style(style);// Set value of cell B1 to 300 as a number type styled with paramaters of styleworksheet.cell(1,2).number(200).style(style);// Set value of cell C1 to a formula styled with paramaters of styleworksheet.cell(1,3).formula('A1 + B1').style(style);// Set value of cell A2 to 'string' styled with paramaters of styleworksheet.cell(2,1).string('string').style(style);// Set value of cell A3 to true as a boolean type styled with paramaters of style but with an adjustment to the font size.worksheet.cell(3,1).bool(true).style(style).style({font: {size: 14}});workbook.write('Excel.xlsx');


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5476822.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存