删除字符串的默认单引号。替换但不起作用

时间:2018-01-14 10:51:21

标签: node.js database excel mongodb data-export

var data = {Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"};

var data2exportforexcel =[data];
//wanted data
  [{Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"}];

//我得到的数据

[ '{Shop : "Shopename", email : "email@gmail.com", name : "name"},{Shop : "Shopename2", email : "email2@gmail.com", name : "name2"}“];

尝试替换data2exportforexcel。但是说它不是函数。

我使用mongoxls插件将数据动态地传输到数据变量,以便将其导出到节点js mongodb中的excel

1 个答案:

答案 0 :(得分:0)

你试过这个吗?

var data2exportforexcel = [JSON.parse(data)];