使用nodejs将数据excel到json

时间:2015-12-28 13:08:52

标签: json node.js xls

这里我需要将我的excel转换为json,因为我只是在正确的路径文件中。运行它时显示以下错误:

[TypeError:无法设置只有getter的[object Object]的属性长度]有什么帮助吗?

node_x = require(" xls-to-json"); var stack = new Error()。stack;

      try{
     node_x({
      input: "Book1.xls",  // input xls 
      output: "output.json" // output json 

    }, function(err, result) {



          if(err) {

             console.error(err);
                     } else {


    console.log(result);
        }

         }); 

    }catch(e){
         console.log("ssfffs");
         console.error(e);
         }

1 个答案:

答案 0 :(得分:0)

尝试输入工作表名称

    node_xj = require("xls-to-json");
  node_xj({
    input: "Book1.xls",  // input xls 
    output: "output.json", // output json 
    sheet: "sheetname"  // specific sheetname 
  }, function(err, result) {
    if(err) {
      console.error(err);
    } else {
      console.log(result);
    }
  });