newLine和Horizo​​n字段json2csv json

时间:2018-10-17 03:30:29

标签: json2csv

var myCars = [       {         “伽玛仪表板”:“”,         “名称:”:“性能报告”,         “日期范围:”:“ 2018-10-16至2018-10-16”,         “ Username:”:“ duong.dang”,         “ ============================”:“,         “ Publisher”:“ Pub。Rev($)”,         “ Yomedia-Ultra”:200.68,         “ Yomedia-Xaxis”:0.55,         “总计”:201.23       },       {         “伽玛仪表板”:“”,         “名称:”: ””,         “日期范围:”: ””,         “用户名:”: ””,         “ ============================”:“,         “ Publisher”:“ Imps”,         “ Yomedia-Ultra”:“ 177,938”,         “ Yomedia-Xaxis”:514,         “总计”:“ 178,452.00”       },     ];

var json2csv = require('json2csv').parse;
const Json2csvParser = require('json2csv').Parser;
//const fields = ['Gamma Dashboard', 'Name'];
//const fieldNames = ['Date range','Username'];
const opts = {
  newLine: '\r\n',
  hasCSVColumnTitle: false,
  withBOM: true,
  excelStrings: true
};

try {
  const parser = new Json2csvParser();
  const csv = parser.parse(myCars);
  console.log(csv);
  //return;
   response.header('content-type', 'application/octet-stream');
   response.header('content-disposition', 'attachment; filename="export.csv"');
   return response.status(200).send(csv);
} catch (err) {
  console.error(err);
}

----但是我喜欢使用结果范围 “伽玛仪表板:”,“” “名称:”,性能 “用户名:”,“ duong.dang” “ ============================”,“” 发行商Yomedia-Ultra Yomedia-Xaxis总计 酒馆修订($)200.68 0.55 201.23 展示次数177,938 514 178,452.00

0 个答案:

没有答案