【问题标题】:excel data to json using nodejs使用nodejs将excel数据转换为json
【发布时间】:2015-12-29 15:50:25
【问题描述】:

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

[TypeError: Cannot set property length of [object Object] which has only a getter]有什么帮助吗?

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);
         }

【问题讨论】:

    标签: json node.js xls


    【解决方案1】:

    也尝试输入工作表名称

        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);
        }
      });
    

    【讨论】:

    • @user4223185 一次尝试使用其他 xls 文件使用相同的代码,以查看在这种情况下是否也会出现该错误。
    • Yupe...用另一个 xls 文件检查相同的错误并检查其数据类型,它显示字符串
    猜你喜欢
    • 2022-10-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-01
    • 2021-08-13
    • 2019-02-16
    • 2015-12-20
    相关资源
    最近更新 更多