我正在尝试将大量 json 数据转换为 excel 并尝试了几个模块以下是我的发现,如果有人使用更好的节点模块来处理更多数据,请告诉我,以便我可以探索
json2xls
一旦我超过它,100000长度的JSON 数组就失败了,并出现此错误402574ms200000FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
节点-xls
带100000长度的JSON 数组444578ms
我在具有 8GB RAM、Intel Core i7、CPU @ 2.10Ghz - 2.70Ghz 的 Windows 7 系统中尝试过这个
小智 8
首先将数据推送到具有所需列的临时数组中,然后将其转换为 xls,我已按以下方式完成:
// use the below package to convert json to xls
var json2xls = require('json2xls');
json.forEach(function(instance, indexx,record){
var tempArry = {
'ColoumnName1' : record[indexx].columnNameVlaue,
'ColoumnName2' : record[indexx].columnNameVlaue,
'ColoumnName3' : record[indexx].columnNameVlaue,
'ColoumnName4' : record[indexx].columnNameVlaue
}
jsonArray.push(tempArry);
});
//this code is for sorting xls with required value
jsonArray.sort(function(a, b) {
return parseFloat(b.ColoumnName4) - parseFloat(a.ColoumnName4);
});
var xls = json2xls(jsonArray);
fs.writeFileSync('yourXLName.xlsx', xls, 'binary');
Run Code Online (Sandbox Code Playgroud)
不要尝试将所有数据添加到 Excel 文件中,使用您想要在文件中保存的特定列。
| 归档时间: |
|
| 查看次数: |
24336 次 |
| 最近记录: |