[英]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.