I’m trying to convert an excel into json.
Tried using “xls-to-json” npm package.
node_xj = require("xls-to-json");
node_xj({
input: "Auto.xlsx", // input xls
output: "output.json", // output json
sheet: "Login" // specific sheetname
}, function (err, result) {
if (err) {
console.error(err);
} else {
console.log(result);
}
});
Above code works fine to write all data in Login sheet to output.json file. I’m unable to figure out what changes I should do to read all sheets in the excel and convert it to one Json.
Or pass values to output: "output.json", and sheet: "Login" dynamically so every sheet data is written into a different Json. Tried :
-
passed sheet: "Login",”Logout” and sheet:”Login,Logout” .
-
Created a Json file, read values from it and passed it to
input: jsonobj.input, // input xls
output: jsonobj.output , // output json
sheet: jsonobj.sheet // specific sheetname
This read the first value and then threw error.
via purplized
No comments:
Post a Comment