[英]how to write all array elements to excel file using exceljs in nodejs
对于这种必须将数据数组放入Excel或CSV文件的要求,我在我的情况下使用fast-csv
,因此我正在为此编写代码。 希望这对您有帮助。 。
您可以使用以下代码:
var fs = require('fs'); // using npm install fs module on application
var csv = require("fast-csv"); // I used this module in my case
var csvFileName = 'path of folder/file.csv';
var stream = fs.createReadStream(csvFileName); //reads the file
var headings = [];
var full = [];
headings.push('head1','head2','head3');
full.push(headings);
var csvStream = csv.createWriteStream({headers: true}),
ws = fs.createWriteStream(file_location);
csv.write(full, {headers: true}).pipe(ws);
ws.on("finish", function(){
response.redirect('/enriched'); // response is response parameter of your callback function
// redirect where you wants
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.