简体   繁体   English

节点导出到Excel

[英]Node export to excel

Im having a very hard time doing the simple task of writing an array of numbers to an excel file. 我很难完成将数字数组写入excel文件的简单任务。

I tried: 我试过了:

var writeStream = fs.createWriteStream(path + "file.xls");

for (var x = 0; x < dataArr.length; x++) {
    // convert to string
    writeStream.write('' + dataArr[x]);
}

writeStream.close();

However, this just keeps writing the array values to the same row. 但是,这只会将数组值写入同一行。 So in the end, theres only one row with the last value. 因此,最后只有一行具有最后一个值。 How is it possible to create a new row each time? 每次如何创建新行?

在循环中,尝试:

writeStream.write('' + dataArr[x] + '\n');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM