我是一个nodejs程序员。现在,我有了要以Excel File格式保存的数据表。我该怎么做呢?
我发现了一些Node库。但是大多数都是Excel解析器而不是Excel Writer。我使用的是Linux Server。因此需要一些可以在Linux上运行的工具。如果您知道任何有用的库,请告诉我。
还是有办法将CSV文件(以编程方式)转换为xls文件?
excel4node是 根据官方规范构建的 本地Excel文件维护者。它与另一个答案中提到的mxexcel- builder相似,但维护性更高。
// Require library var excel = require('excel4node'); // Create a new instance of a Workbook class var workbook = new excel.Workbook(); // Add Worksheets to the workbook var worksheet = workbook.addWorksheet('Sheet 1'); var worksheet2 = workbook.addWorksheet('Sheet 2'); // Create a reusable style var 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 style worksheet.cell(1,1).number(100).style(style); // Set value of cell B1 to 300 as a number type styled with paramaters of style worksheet.cell(1,2).number(200).style(style); // Set value of cell C1 to a formula styled with paramaters of style worksheet.cell(1,3).formula('A1 + B1').style(style); // Set value of cell A2 to 'string' styled with paramaters of style worksheet.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');