node.js - 使用 Node JS 将 Excel 转换为 JSON

标签 node.js xls

我一直在尝试将excel工作表数据转换为json格式,并且我已经有各种模块,例如“xls-to-json”,“xls-to-json-lc”,“node-excel-to-json”,到目前为止我得到了空响应。

我的示例代码如下:

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

我的 Excel 工作表包含非常简单的数据:

enter image description here

我在这方面做错了什么,我正在获取文件及其有效路径。

最佳答案

得到了解决方案,所有库都将第一行视为标题,因此它没有显示,当我添加第二行时它才显示,并且每个模块都有自己的输出/响应结构。一些模块在输出中考虑 Excel 标题并跳过第一行,少数模块包含第一行。

关于node.js - 使用 Node JS 将 Excel 转换为 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47497095/

相关文章:

javascript - 尝试安装 grunt 时出错

excel - 如何在Lua中读取并解析excel文件?

python - 使用 python 将 tsv 文件转换为 xls/xlsx

python - 使用 Python 读取/解析 Excel (xls) 文件

python - os.system ('TASKKILL/F/IM EXCEL.exe' ) 在 python 中

node.js - Kendo UI Angular 将文件作为 Node.JS 上传到后端

javascript - Mocha 测试中的共享功能

html - 使用xml注释生成格式化的html输出

javascript - AngularJS 不显示 ng-repeat,只显示一个空列表

javascript - 如何将获取的 JSON 保存在变量中 [node-fetch]