【问题标题】:Converting multiple excel files to json将多个excel文件转换为json
【发布时间】:2015-04-16 03:35:40
【问题描述】:

我正在尝试将multiple excel files 转换为multiple json files。我一直在研究一些 nodejs 库,但不确定哪个库适合。有没有library或者可以读取多个excel文件并将它们转换为对应的json文件的方式。

我在看这个特殊的图书馆。 https://www.npmjs.com/package/convert-json

var cv2json = require('../');

var csv_trans = cv2json.xls('./test/test.xls', options /* optional */, function(err, result) {
  if(err)
    console.error(err);
  else 
    console.log(result);
    // result should be a json object or array. 
})

我看到他们正在传递一个 excel 文件并将其转换为 json-object。有没有办法我们可以传递多个文件参数并取回它们对应的 json 对象。

【问题讨论】:

    标签: javascript json node.js excel


    【解决方案1】:

    只用循环

    var files = [
      './path/to/file1.xls',
      './path/to/file2.xls'
    ]
    
    files.forEach(function(file) {
      cv2json.xls(file, function(err, result) {
        // do something with result
      }) 
    })
    

    【讨论】:

      猜你喜欢
      • 2016-12-18
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2018-11-14
      • 2015-04-01
      • 1970-01-01
      • 2023-02-14
      相关资源
      最近更新 更多