我一直在尝试将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 工作表包含非常简单的数据:
我在这方面做错了什么,我正在获取文件及其有效路径。
最佳答案
得到了解决方案,所有库都将第一行视为标题,因此它没有显示,当我添加第二行时它才显示,并且每个模块都有自己的输出/响应结构。一些模块在输出中考虑 Excel 标题并跳过第一行,少数模块包含第一行。
关于node.js - 使用 Node JS 将 Excel 转换为 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47497095/